github.com/ethersphere/bee/v2@v2.2.0/pkg/config/chain.go (about) 1 // Copyright 2021 The Swarm Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package config 6 7 import ( 8 _ "embed" 9 10 "github.com/ethereum/go-ethereum/common" 11 "github.com/ethersphere/go-storage-incentives-abi/abi" 12 ) 13 14 // TODO: consider adding BzzAddress (also as a cmd param) to the ChainConfig and remove the postagecontract.LookupERC20Address function. 15 16 type ChainConfig struct { 17 // General. 18 ChainID int64 19 NetworkID uint64 20 PostageStampStartBlock uint64 21 NativeTokenSymbol string 22 SwarmTokenSymbol string 23 24 // Addresses. 25 StakingAddress common.Address 26 PostageStampAddress common.Address 27 RedistributionAddress common.Address 28 SwapPriceOracleAddress common.Address 29 CurrentFactoryAddress common.Address 30 31 // ABIs. 32 StakingABI string 33 PostageStampABI string 34 RedistributionABI string 35 } 36 37 var ( 38 Testnet = ChainConfig{ 39 ChainID: abi.TestnetChainID, 40 NetworkID: abi.TestnetNetworkID, 41 PostageStampStartBlock: abi.TestnetPostageStampBlockNumber, 42 NativeTokenSymbol: "ETH", 43 SwarmTokenSymbol: "sBZZ", 44 45 StakingAddress: common.HexToAddress(abi.TestnetStakingAddress), 46 PostageStampAddress: common.HexToAddress(abi.TestnetPostageStampAddress), 47 RedistributionAddress: common.HexToAddress(abi.TestnetRedistributionAddress), 48 SwapPriceOracleAddress: common.HexToAddress("0xe821533d30A4250e50812Aa060EEb2E8Ef3D98f6"), 49 CurrentFactoryAddress: common.HexToAddress("0x0fF044F6bB4F684a5A149B46D7eC03ea659F98A1"), 50 51 StakingABI: abi.TestnetStakingABI, 52 PostageStampABI: abi.TestnetPostageStampABI, 53 RedistributionABI: abi.TestnetRedistributionABI, 54 } 55 56 Mainnet = ChainConfig{ 57 ChainID: abi.MainnetChainID, 58 NetworkID: abi.MainnetNetworkID, 59 PostageStampStartBlock: abi.MainnetPostageStampBlockNumber, 60 NativeTokenSymbol: "xDAI", 61 SwarmTokenSymbol: "xBZZ", 62 63 StakingAddress: common.HexToAddress(abi.MainnetStakingAddress), 64 PostageStampAddress: common.HexToAddress(abi.MainnetPostageStampAddress), 65 RedistributionAddress: common.HexToAddress(abi.MainnetRedistributionAddress), 66 SwapPriceOracleAddress: common.HexToAddress("0x0FDc5429C50e2a39066D8A94F3e2D2476fcc3b85"), 67 CurrentFactoryAddress: common.HexToAddress("0xc2d5a532cf69aa9a1378737d8ccdef884b6e7420"), 68 69 StakingABI: abi.MainnetStakingABI, 70 PostageStampABI: abi.MainnetPostageStampABI, 71 RedistributionABI: abi.MainnetRedistributionABI, 72 } 73 ) 74 75 func GetByChainID(chainID int64) (ChainConfig, bool) { 76 switch chainID { 77 case Testnet.ChainID: 78 return Testnet, true 79 case Mainnet.ChainID: 80 return Mainnet, true 81 default: 82 return ChainConfig{ 83 NativeTokenSymbol: Testnet.NativeTokenSymbol, 84 SwarmTokenSymbol: Testnet.SwarmTokenSymbol, 85 StakingABI: abi.TestnetStakingABI, 86 PostageStampABI: abi.TestnetPostageStampABI, 87 RedistributionABI: abi.TestnetRedistributionABI, 88 }, false 89 } 90 }