github.com/smartcontractkit/chainlink-testing-framework/libs@v0.0.0-20240227141906-ec710b4eb1a3/networks/known_networks.go (about)

     1  // Package networks holds all known network information for the tests
     2  package networks
     3  
     4  import (
     5  	"crypto/ecdsa"
     6  	"fmt"
     7  	"strings"
     8  	"time"
     9  
    10  	"github.com/ethereum/go-ethereum/crypto"
    11  	"github.com/rs/zerolog/log"
    12  
    13  	"github.com/smartcontractkit/chainlink-testing-framework/libs/blockchain"
    14  	"github.com/smartcontractkit/chainlink-testing-framework/libs/config"
    15  )
    16  
    17  // Pre-configured test networks and their connections
    18  // Some networks with public RPC endpoints are already filled out, but make use of environment variables to use info like
    19  // private RPC endpoints and private keys.
    20  var (
    21  	// To create replica of simulated EVM network, with different chain ids
    22  	AdditionalSimulatedChainIds = []int64{3337, 4337, 5337, 6337, 7337, 8337, 9337, 9338}
    23  	AdditionalSimulatedPvtKeys  = []string{
    24  		"5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a",
    25  		"7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6",
    26  		"47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a",
    27  		"8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba",
    28  		"92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e",
    29  		"4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356",
    30  		"dbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97",
    31  		"2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6",
    32  		"f214f2b2cd398c806f84e317254e0f0b801d0643303237d97a22a48e01628897",
    33  		"701b615bbdfb9de65240bc28bd21bbc0d996645a3dd57e7b12bc2bdf6f192c82",
    34  		"a267530f49f8280200edf313ee7af6b827f2a8bce2897751d06a843f644967b1",
    35  		"47c99abed3324a2707c28affff1267e45918ec8c3f20b8aa892e8b065d2942dd",
    36  		"c526ee95bf44d8fc405a158bb884d9d1238d99f0612e9f33d006bb0789009aaa",
    37  		"8166f546bab6da521a8369cab06c5d2b9e46670292d85c875ee9ec20e84ffb61",
    38  		"ea6c44ac03bff858b476bba40716402b03e41b8e97e276d1baec7c37d42484a0",
    39  		"689af8efa8c651a91ad287602527f3af2fe9f6501a7ac4b061667b5a93e037fd",
    40  		"de9be858da4a475276426320d5e9262ecfc3ba460bfac56360bfa6c4c28b4ee0",
    41  		"df57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e",
    42  	}
    43  
    44  	// SimulatedEVM represents a simulated network
    45  	SimulatedEVM blockchain.EVMNetwork = blockchain.SimulatedEVMNetwork
    46  	// generalEVM is a customizable network through environment variables
    47  	// This is getting little use, and causes some confusion. Can re-enable if people want it.
    48  	// generalEVM blockchain.EVMNetwork = blockchain.LoadNetworkFromEnvironment()
    49  
    50  	// SimulatedevmNonDev1 represents a simulated network which can be used to deploy a non-dev geth node
    51  	SimulatedEVMNonDev1 = blockchain.EVMNetwork{
    52  		Name:                 "source-chain",
    53  		Simulated:            true,
    54  		ClientImplementation: blockchain.EthereumClientImplementation,
    55  		SupportsEIP1559:      true,
    56  		ChainID:              1337,
    57  		PrivateKeys: []string{
    58  			"ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
    59  		},
    60  		URLs:                      []string{"ws://source-chain-ethereum-geth:8546"},
    61  		HTTPURLs:                  []string{"http://source-chain-ethereum-geth:8544"},
    62  		ChainlinkTransactionLimit: 500000,
    63  		Timeout:                   blockchain.StrDuration{Duration: 2 * time.Minute},
    64  		MinimumConfirmations:      1,
    65  		GasEstimationBuffer:       10000,
    66  		DefaultGasLimit:           6000000,
    67  	}
    68  
    69  	// SimulatedEVM_NON_DEV_2 represents a simulated network with chain id 2337 which can be used to deploy a non-dev geth node
    70  	SimulatedEVMNonDev2 = blockchain.EVMNetwork{
    71  		Name:                 "dest-chain",
    72  		Simulated:            true,
    73  		SupportsEIP1559:      true,
    74  		ClientImplementation: blockchain.EthereumClientImplementation,
    75  		ChainID:              2337,
    76  		PrivateKeys: []string{
    77  			"59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d",
    78  		},
    79  		URLs:                      []string{"ws://dest-chain-ethereum-geth:8546"},
    80  		HTTPURLs:                  []string{"http://dest-chain-ethereum-geth:8544"},
    81  		ChainlinkTransactionLimit: 500000,
    82  		Timeout:                   blockchain.StrDuration{Duration: 2 * time.Minute},
    83  		MinimumConfirmations:      1,
    84  		GasEstimationBuffer:       10000,
    85  		DefaultGasLimit:           6000000,
    86  	}
    87  
    88  	// SimulatedBesuNonDev1 represents a simulated network which can be used to deploy a non-dev besu node
    89  	// in a CCIP source-chain -> dest-chain communication
    90  	SimulatedBesuNonDev1 = blockchain.EVMNetwork{
    91  		Name:                 "source-chain",
    92  		Simulated:            true,
    93  		ClientImplementation: blockchain.EthereumClientImplementation,
    94  		SupportsEIP1559:      false,
    95  		SimulationType:       "besu",
    96  		ChainID:              1337,
    97  		PrivateKeys: []string{
    98  			"ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
    99  		},
   100  		URLs:                      []string{"ws://source-chain-ethereum-besu:8546"},
   101  		HTTPURLs:                  []string{"http://source-chain-ethereum-besu:8544"},
   102  		ChainlinkTransactionLimit: 500000,
   103  		Timeout:                   blockchain.StrDuration{Duration: 2 * time.Minute},
   104  		MinimumConfirmations:      1,
   105  		GasEstimationBuffer:       10000,
   106  		DefaultGasLimit:           6000000,
   107  	}
   108  
   109  	// SimulatedBesuNonDev2 represents a simulated network which can be used to deploy a non-dev besu node
   110  	// in a CCIP source-chain -> dest-chain communication
   111  	SimulatedBesuNonDev2 = blockchain.EVMNetwork{
   112  		Name:                 "dest-chain",
   113  		Simulated:            true,
   114  		ClientImplementation: blockchain.EthereumClientImplementation,
   115  		SupportsEIP1559:      false,
   116  		SimulationType:       "besu",
   117  		ChainID:              2337,
   118  		PrivateKeys: []string{
   119  			"59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d",
   120  		},
   121  		URLs:                      []string{"ws://dest-chain-ethereum-besu:8546"},
   122  		HTTPURLs:                  []string{"http://dest-chain-ethereum-besu:8544"},
   123  		ChainlinkTransactionLimit: 500000,
   124  		Timeout:                   blockchain.StrDuration{Duration: 2 * time.Minute},
   125  		MinimumConfirmations:      1,
   126  		GasEstimationBuffer:       10000,
   127  		DefaultGasLimit:           6000000,
   128  	}
   129  
   130  	SimulatedEVMNonDev = blockchain.EVMNetwork{
   131  		Name:                 "geth",
   132  		Simulated:            true,
   133  		SupportsEIP1559:      true,
   134  		ClientImplementation: blockchain.EthereumClientImplementation,
   135  		ChainID:              1337,
   136  		PrivateKeys: []string{
   137  			"ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
   138  		},
   139  		URLs:                      []string{"ws://geth-ethereum-geth:8546"},
   140  		HTTPURLs:                  []string{"http://geth-ethereum-geth:8544"},
   141  		ChainlinkTransactionLimit: 500000,
   142  		Timeout:                   blockchain.StrDuration{Duration: 2 * time.Minute},
   143  		MinimumConfirmations:      1,
   144  		GasEstimationBuffer:       10000,
   145  	}
   146  
   147  	EthereumMainnet blockchain.EVMNetwork = blockchain.EVMNetwork{
   148  		Name:                      "Ethereum Mainnet",
   149  		SupportsEIP1559:           true,
   150  		ClientImplementation:      blockchain.EthereumClientImplementation,
   151  		ChainID:                   1,
   152  		Simulated:                 false,
   153  		ChainlinkTransactionLimit: 5000,
   154  		Timeout:                   blockchain.StrDuration{Duration: 5 * time.Minute},
   155  		MinimumConfirmations:      1,
   156  		GasEstimationBuffer:       0,
   157  		FinalityTag:               true,
   158  		DefaultGasLimit:           6000000,
   159  	}
   160  
   161  	// sepoliaTestnet https://sepolia.dev/
   162  	SepoliaTestnet blockchain.EVMNetwork = blockchain.EVMNetwork{
   163  		Name:                      "Sepolia Testnet",
   164  		SupportsEIP1559:           true,
   165  		ClientImplementation:      blockchain.EthereumClientImplementation,
   166  		ChainID:                   11155111,
   167  		Simulated:                 false,
   168  		ChainlinkTransactionLimit: 5000,
   169  		Timeout:                   blockchain.StrDuration{Duration: 5 * time.Minute},
   170  		MinimumConfirmations:      1,
   171  		GasEstimationBuffer:       1000,
   172  		FinalityTag:               true,
   173  		DefaultGasLimit:           6000000,
   174  	}
   175  
   176  	// goerliTestnet https://goerli.net/
   177  	GoerliTestnet blockchain.EVMNetwork = blockchain.EVMNetwork{
   178  		Name:                      "Goerli Testnet",
   179  		SupportsEIP1559:           true,
   180  		ClientImplementation:      blockchain.EthereumClientImplementation,
   181  		ChainID:                   5,
   182  		Simulated:                 false,
   183  		ChainlinkTransactionLimit: 5000,
   184  		Timeout:                   blockchain.StrDuration{Duration: 5 * time.Minute},
   185  		MinimumConfirmations:      1,
   186  		GasEstimationBuffer:       1000,
   187  		FinalityTag:               true,
   188  		DefaultGasLimit:           6000000,
   189  	}
   190  
   191  	KlaytnMainnet blockchain.EVMNetwork = blockchain.EVMNetwork{
   192  		Name:                      "Klaytn Mainnet",
   193  		SupportsEIP1559:           false,
   194  		ClientImplementation:      blockchain.KlaytnClientImplementation,
   195  		ChainID:                   8217,
   196  		Simulated:                 false,
   197  		ChainlinkTransactionLimit: 5000,
   198  		Timeout:                   blockchain.StrDuration{Duration: time.Minute},
   199  		MinimumConfirmations:      1,
   200  		GasEstimationBuffer:       0,
   201  	}
   202  
   203  	// klaytnBaobab https://klaytn.foundation/
   204  	KlaytnBaobab blockchain.EVMNetwork = blockchain.EVMNetwork{
   205  		Name:                      "Klaytn Baobab",
   206  		SupportsEIP1559:           false,
   207  		ClientImplementation:      blockchain.KlaytnClientImplementation,
   208  		ChainID:                   1001,
   209  		Simulated:                 false,
   210  		ChainlinkTransactionLimit: 5000,
   211  		Timeout:                   blockchain.StrDuration{Duration: time.Minute},
   212  		MinimumConfirmations:      1,
   213  		GasEstimationBuffer:       0,
   214  	}
   215  
   216  	MetisAndromeda blockchain.EVMNetwork = blockchain.EVMNetwork{
   217  		Name:                      "Metis Andromeda",
   218  		SupportsEIP1559:           false,
   219  		ClientImplementation:      blockchain.MetisClientImplementation,
   220  		ChainID:                   1088,
   221  		Simulated:                 false,
   222  		ChainlinkTransactionLimit: 5000,
   223  		Timeout:                   blockchain.StrDuration{Duration: time.Minute},
   224  		MinimumConfirmations:      1,
   225  		GasEstimationBuffer:       0,
   226  	}
   227  
   228  	// metisStardust https://www.metis.io/
   229  	MetisStardust blockchain.EVMNetwork = blockchain.EVMNetwork{
   230  		Name:                      "Metis Stardust",
   231  		SupportsEIP1559:           false,
   232  		ClientImplementation:      blockchain.MetisClientImplementation,
   233  		ChainID:                   588,
   234  		Simulated:                 false,
   235  		ChainlinkTransactionLimit: 5000,
   236  		Timeout:                   blockchain.StrDuration{Duration: time.Minute},
   237  		MinimumConfirmations:      1,
   238  		GasEstimationBuffer:       1000,
   239  	}
   240  
   241  	ArbitrumMainnet blockchain.EVMNetwork = blockchain.EVMNetwork{
   242  		Name:                      "Arbitrum Mainnet",
   243  		SupportsEIP1559:           true,
   244  		ClientImplementation:      blockchain.ArbitrumClientImplementation,
   245  		ChainID:                   42161,
   246  		Simulated:                 false,
   247  		ChainlinkTransactionLimit: 5000,
   248  		Timeout:                   blockchain.StrDuration{Duration: 2 * time.Minute},
   249  		MinimumConfirmations:      0,
   250  		GasEstimationBuffer:       0,
   251  		FinalityTag:               true,
   252  		DefaultGasLimit:           100000000,
   253  	}
   254  
   255  	// arbitrumGoerli https://developer.offchainlabs.com/docs/public_chains
   256  	ArbitrumGoerli blockchain.EVMNetwork = blockchain.EVMNetwork{
   257  		Name:                      "Arbitrum Goerli",
   258  		SupportsEIP1559:           true,
   259  		ClientImplementation:      blockchain.ArbitrumClientImplementation,
   260  		ChainID:                   421613,
   261  		Simulated:                 false,
   262  		ChainlinkTransactionLimit: 5000,
   263  		Timeout:                   blockchain.StrDuration{Duration: 2 * time.Minute},
   264  		MinimumConfirmations:      0,
   265  		GasEstimationBuffer:       0,
   266  		FinalityTag:               true,
   267  		DefaultGasLimit:           100000000,
   268  	}
   269  
   270  	ArbitrumSepolia blockchain.EVMNetwork = blockchain.EVMNetwork{
   271  		Name:                      "Arbitrum Sepolia",
   272  		SupportsEIP1559:           true,
   273  		ClientImplementation:      blockchain.ArbitrumClientImplementation,
   274  		ChainID:                   421614,
   275  		Simulated:                 false,
   276  		ChainlinkTransactionLimit: 5000,
   277  		Timeout:                   blockchain.StrDuration{Duration: 2 * time.Minute},
   278  		MinimumConfirmations:      0,
   279  		GasEstimationBuffer:       0,
   280  		FinalityTag:               true,
   281  		DefaultGasLimit:           100000000,
   282  	}
   283  
   284  	OptimismMainnet blockchain.EVMNetwork = blockchain.EVMNetwork{
   285  		Name:                      "Optimism Mainnet",
   286  		SupportsEIP1559:           true,
   287  		ClientImplementation:      blockchain.OptimismClientImplementation,
   288  		ChainID:                   10,
   289  		Simulated:                 false,
   290  		ChainlinkTransactionLimit: 5000,
   291  		Timeout:                   blockchain.StrDuration{Duration: 3 * time.Minute},
   292  		MinimumConfirmations:      0,
   293  		GasEstimationBuffer:       0,
   294  		FinalityTag:               true,
   295  		DefaultGasLimit:           6000000,
   296  	}
   297  
   298  	// OptimismGoerli https://dev.optimism.io/kovan-to-goerli/
   299  	OptimismGoerli blockchain.EVMNetwork = blockchain.EVMNetwork{
   300  		Name:                      "Optimism Goerli",
   301  		SupportsEIP1559:           true,
   302  		ClientImplementation:      blockchain.OptimismClientImplementation,
   303  		ChainID:                   420,
   304  		Simulated:                 false,
   305  		ChainlinkTransactionLimit: 5000,
   306  		Timeout:                   blockchain.StrDuration{Duration: 3 * time.Minute},
   307  		MinimumConfirmations:      0,
   308  		GasEstimationBuffer:       0,
   309  		FinalityTag:               true,
   310  		DefaultGasLimit:           6000000,
   311  	}
   312  
   313  	// OptimismSepolia https://community.optimism.io/docs/useful-tools/networks/#parameters-for-node-operators-2
   314  	OptimismSepolia blockchain.EVMNetwork = blockchain.EVMNetwork{
   315  		Name:                      "Optimism Sepolia",
   316  		SupportsEIP1559:           true,
   317  		ClientImplementation:      blockchain.OptimismClientImplementation,
   318  		ChainID:                   11155420,
   319  		Simulated:                 false,
   320  		ChainlinkTransactionLimit: 5000,
   321  		Timeout:                   blockchain.StrDuration{Duration: 3 * time.Minute},
   322  		MinimumConfirmations:      0,
   323  		GasEstimationBuffer:       0,
   324  		FinalityTag:               true,
   325  		DefaultGasLimit:           6000000,
   326  	}
   327  
   328  	RSKMainnet blockchain.EVMNetwork = blockchain.EVMNetwork{
   329  		Name:                      "RSK Mainnet",
   330  		SupportsEIP1559:           false,
   331  		ClientImplementation:      blockchain.RSKClientImplementation,
   332  		ChainID:                   30,
   333  		Simulated:                 false,
   334  		ChainlinkTransactionLimit: 5000,
   335  		Timeout:                   blockchain.StrDuration{Duration: time.Minute},
   336  		MinimumConfirmations:      1,
   337  		GasEstimationBuffer:       1000,
   338  	}
   339  
   340  	// rskTestnet https://www.rsk.co/
   341  	RSKTestnet blockchain.EVMNetwork = blockchain.EVMNetwork{
   342  		Name:                      "RSK Testnet",
   343  		SupportsEIP1559:           false,
   344  		ClientImplementation:      blockchain.RSKClientImplementation,
   345  		ChainID:                   31,
   346  		Simulated:                 false,
   347  		ChainlinkTransactionLimit: 5000,
   348  		Timeout:                   blockchain.StrDuration{Duration: time.Minute},
   349  		MinimumConfirmations:      1,
   350  		GasEstimationBuffer:       1000,
   351  	}
   352  
   353  	PolygonMainnet blockchain.EVMNetwork = blockchain.EVMNetwork{
   354  		Name:                      "Polygon Mainnet",
   355  		SupportsEIP1559:           true,
   356  		ClientImplementation:      blockchain.PolygonClientImplementation,
   357  		ChainID:                   137,
   358  		Simulated:                 false,
   359  		ChainlinkTransactionLimit: 5000,
   360  		Timeout:                   blockchain.StrDuration{Duration: 3 * time.Minute},
   361  		MinimumConfirmations:      1,
   362  		GasEstimationBuffer:       0,
   363  		FinalityTag:               true,
   364  		DefaultGasLimit:           6000000,
   365  	}
   366  
   367  	// PolygonMumbai https://mumbai.polygonscan.com/
   368  	PolygonMumbai blockchain.EVMNetwork = blockchain.EVMNetwork{
   369  		Name:                      "Polygon Mumbai",
   370  		SupportsEIP1559:           true,
   371  		ClientImplementation:      blockchain.PolygonClientImplementation,
   372  		ChainID:                   80001,
   373  		Simulated:                 false,
   374  		ChainlinkTransactionLimit: 5000,
   375  		Timeout:                   blockchain.StrDuration{Duration: 3 * time.Minute},
   376  		MinimumConfirmations:      1,
   377  		GasEstimationBuffer:       1000,
   378  		FinalityTag:               true,
   379  		DefaultGasLimit:           6000000,
   380  	}
   381  
   382  	AvalancheMainnet blockchain.EVMNetwork = blockchain.EVMNetwork{
   383  		Name:                      "Avalanche Mainnet",
   384  		SupportsEIP1559:           true,
   385  		ClientImplementation:      blockchain.EthereumClientImplementation,
   386  		ChainID:                   43114,
   387  		Simulated:                 false,
   388  		ChainlinkTransactionLimit: 5000,
   389  		Timeout:                   blockchain.StrDuration{Duration: 2 * time.Minute},
   390  		MinimumConfirmations:      1,
   391  		GasEstimationBuffer:       0,
   392  		FinalityTag:               true,
   393  		DefaultGasLimit:           6000000,
   394  	}
   395  
   396  	AvalancheFuji = blockchain.EVMNetwork{
   397  		Name:                      "Avalanche Fuji",
   398  		SupportsEIP1559:           true,
   399  		ClientImplementation:      blockchain.EthereumClientImplementation,
   400  		ChainID:                   43113,
   401  		Simulated:                 false,
   402  		ChainlinkTransactionLimit: 5000,
   403  		Timeout:                   blockchain.StrDuration{Duration: 2 * time.Minute},
   404  		MinimumConfirmations:      1,
   405  		GasEstimationBuffer:       1000,
   406  		FinalityTag:               true,
   407  		DefaultGasLimit:           6000000,
   408  	}
   409  
   410  	Quorum = blockchain.EVMNetwork{
   411  		Name:                      "Quorum",
   412  		SupportsEIP1559:           false,
   413  		ClientImplementation:      blockchain.QuorumClientImplementation,
   414  		ChainID:                   1337,
   415  		Simulated:                 false,
   416  		ChainlinkTransactionLimit: 5000,
   417  		Timeout:                   blockchain.StrDuration{Duration: time.Minute},
   418  		MinimumConfirmations:      1,
   419  		GasEstimationBuffer:       0,
   420  	}
   421  
   422  	BaseGoerli blockchain.EVMNetwork = blockchain.EVMNetwork{
   423  		Name:                      "Base Goerli",
   424  		SupportsEIP1559:           true,
   425  		ClientImplementation:      blockchain.OptimismClientImplementation,
   426  		ChainID:                   84531,
   427  		Simulated:                 false,
   428  		ChainlinkTransactionLimit: 5000,
   429  		Timeout:                   blockchain.StrDuration{Duration: 3 * time.Minute},
   430  		MinimumConfirmations:      0,
   431  		GasEstimationBuffer:       0,
   432  		FinalityTag:               true,
   433  		DefaultGasLimit:           6000000,
   434  	}
   435  
   436  	// BaseSepolia https://base.mirror.xyz/kkz1-KFdUwl0n23PdyBRtnFewvO48_m-fZNzPMJehM4
   437  	BaseSepolia blockchain.EVMNetwork = blockchain.EVMNetwork{
   438  		Name:                      "Base Sepolia",
   439  		SupportsEIP1559:           true,
   440  		ClientImplementation:      blockchain.OptimismClientImplementation,
   441  		ChainID:                   84532,
   442  		Simulated:                 false,
   443  		ChainlinkTransactionLimit: 5000,
   444  		Timeout:                   blockchain.StrDuration{Duration: 3 * time.Minute},
   445  		MinimumConfirmations:      0,
   446  		GasEstimationBuffer:       0,
   447  		FinalityTag:               true,
   448  		DefaultGasLimit:           6000000,
   449  	}
   450  
   451  	CeloAlfajores = blockchain.EVMNetwork{
   452  		Name:                      "Celo Alfajores",
   453  		SupportsEIP1559:           false,
   454  		ClientImplementation:      blockchain.CeloClientImplementation,
   455  		ChainID:                   44787,
   456  		Simulated:                 false,
   457  		ChainlinkTransactionLimit: 5000,
   458  		Timeout:                   blockchain.StrDuration{Duration: 3 * time.Minute},
   459  		MinimumConfirmations:      1,
   460  		GasEstimationBuffer:       1000,
   461  	}
   462  
   463  	ScrollSepolia = blockchain.EVMNetwork{
   464  		Name:                      "Scroll Sepolia",
   465  		ClientImplementation:      blockchain.ScrollClientImplementation,
   466  		ChainID:                   534351,
   467  		Simulated:                 false,
   468  		ChainlinkTransactionLimit: 5000,
   469  		Timeout:                   blockchain.StrDuration{Duration: 3 * time.Minute},
   470  		MinimumConfirmations:      1,
   471  		GasEstimationBuffer:       0,
   472  	}
   473  
   474  	ScrollMainnet = blockchain.EVMNetwork{
   475  		Name:                      "Scroll Mainnet",
   476  		ClientImplementation:      blockchain.ScrollClientImplementation,
   477  		ChainID:                   534352,
   478  		Simulated:                 false,
   479  		ChainlinkTransactionLimit: 5000,
   480  		Timeout:                   blockchain.StrDuration{Duration: 3 * time.Minute},
   481  		MinimumConfirmations:      1,
   482  		GasEstimationBuffer:       0,
   483  	}
   484  
   485  	CeloMainnet = blockchain.EVMNetwork{
   486  		Name:                      "Celo",
   487  		ClientImplementation:      blockchain.CeloClientImplementation,
   488  		ChainID:                   42220,
   489  		Simulated:                 false,
   490  		ChainlinkTransactionLimit: 5000,
   491  		Timeout:                   blockchain.StrDuration{Duration: time.Minute},
   492  		MinimumConfirmations:      1,
   493  		GasEstimationBuffer:       1000,
   494  	}
   495  
   496  	BaseMainnet blockchain.EVMNetwork = blockchain.EVMNetwork{
   497  		Name:                      "Base Mainnet",
   498  		SupportsEIP1559:           true,
   499  		ClientImplementation:      blockchain.OptimismClientImplementation,
   500  		ChainID:                   8453,
   501  		Simulated:                 false,
   502  		ChainlinkTransactionLimit: 5000,
   503  		Timeout:                   blockchain.StrDuration{Duration: 3 * time.Minute},
   504  		MinimumConfirmations:      0,
   505  		GasEstimationBuffer:       0,
   506  		FinalityTag:               true,
   507  		DefaultGasLimit:           6000000,
   508  	}
   509  
   510  	BSCTestnet blockchain.EVMNetwork = blockchain.EVMNetwork{
   511  		Name:                      "BSC Testnet",
   512  		SupportsEIP1559:           true,
   513  		ClientImplementation:      blockchain.BSCClientImplementation,
   514  		ChainID:                   97,
   515  		Simulated:                 false,
   516  		ChainlinkTransactionLimit: 5000,
   517  		Timeout:                   blockchain.StrDuration{Duration: 2 * time.Minute},
   518  		MinimumConfirmations:      3,
   519  		GasEstimationBuffer:       0,
   520  		FinalityTag:               true,
   521  		DefaultGasLimit:           6000000,
   522  	}
   523  
   524  	BSCMainnet blockchain.EVMNetwork = blockchain.EVMNetwork{
   525  		Name:                      "BSC Mainnet",
   526  		SupportsEIP1559:           true,
   527  		ClientImplementation:      blockchain.BSCClientImplementation,
   528  		ChainID:                   56,
   529  		Simulated:                 false,
   530  		ChainlinkTransactionLimit: 5000,
   531  		Timeout:                   blockchain.StrDuration{Duration: 2 * time.Minute},
   532  		MinimumConfirmations:      3,
   533  		GasEstimationBuffer:       0,
   534  		FinalityTag:               true,
   535  		DefaultGasLimit:           6000000,
   536  	}
   537  
   538  	LineaGoerli blockchain.EVMNetwork = blockchain.EVMNetwork{
   539  		Name:                      "Linea Goerli",
   540  		SupportsEIP1559:           true,
   541  		ClientImplementation:      blockchain.LineaClientImplementation,
   542  		ChainID:                   59140,
   543  		Simulated:                 false,
   544  		ChainlinkTransactionLimit: 5000,
   545  		Timeout:                   blockchain.StrDuration{Duration: 3 * time.Minute},
   546  		MinimumConfirmations:      0,
   547  		GasEstimationBuffer:       1000,
   548  	}
   549  
   550  	LineaMainnet blockchain.EVMNetwork = blockchain.EVMNetwork{
   551  		Name:                      "Linea Mainnet",
   552  		SupportsEIP1559:           true,
   553  		ClientImplementation:      blockchain.LineaClientImplementation,
   554  		ChainID:                   59144,
   555  		Simulated:                 false,
   556  		ChainlinkTransactionLimit: 5000,
   557  		Timeout:                   blockchain.StrDuration{Duration: 3 * time.Minute},
   558  		MinimumConfirmations:      1,
   559  		GasEstimationBuffer:       1000,
   560  	}
   561  
   562  	PolygonZkEvmGoerli = blockchain.EVMNetwork{
   563  		Name:                      "Polygon zkEVM Goerli",
   564  		SupportsEIP1559:           false,
   565  		ClientImplementation:      blockchain.PolygonZkEvmClientImplementation,
   566  		ChainID:                   1442,
   567  		Simulated:                 false,
   568  		ChainlinkTransactionLimit: 5000,
   569  		Timeout:                   blockchain.StrDuration{Duration: time.Minute},
   570  		MinimumConfirmations:      0,
   571  		GasEstimationBuffer:       1000,
   572  	}
   573  
   574  	PolygonZkEvmMainnet = blockchain.EVMNetwork{
   575  		Name:                      "Polygon zkEVM Mainnet",
   576  		SupportsEIP1559:           false,
   577  		ClientImplementation:      blockchain.PolygonZkEvmClientImplementation,
   578  		ChainID:                   1101,
   579  		Simulated:                 false,
   580  		ChainlinkTransactionLimit: 5000,
   581  		Timeout:                   blockchain.StrDuration{Duration: time.Minute},
   582  		MinimumConfirmations:      0,
   583  		GasEstimationBuffer:       1000,
   584  	}
   585  
   586  	PolygonZkEvmCardona = blockchain.EVMNetwork{
   587  		Name:                      "Polygon zkEVM Cardona",
   588  		SupportsEIP1559:           false,
   589  		ClientImplementation:      blockchain.PolygonZkEvmClientImplementation,
   590  		ChainID:                   2442,
   591  		Simulated:                 false,
   592  		ChainlinkTransactionLimit: 5000,
   593  		Timeout:                   blockchain.StrDuration{Duration: time.Minute},
   594  		MinimumConfirmations:      0,
   595  		GasEstimationBuffer:       1000,
   596  	}
   597  
   598  	WeMixTestnet blockchain.EVMNetwork = blockchain.EVMNetwork{
   599  		Name:                      "WeMix Testnet",
   600  		SupportsEIP1559:           true,
   601  		ClientImplementation:      blockchain.WeMixClientImplementation,
   602  		ChainID:                   1112,
   603  		Simulated:                 false,
   604  		ChainlinkTransactionLimit: 5000,
   605  		Timeout:                   blockchain.StrDuration{Duration: time.Minute},
   606  		MinimumConfirmations:      1,
   607  		GasEstimationBuffer:       0,
   608  		FinalityTag:               true,
   609  		DefaultGasLimit:           6000000,
   610  	}
   611  
   612  	WeMixMainnet blockchain.EVMNetwork = blockchain.EVMNetwork{
   613  		Name:                      "WeMix Mainnet",
   614  		SupportsEIP1559:           true,
   615  		ClientImplementation:      blockchain.WeMixClientImplementation,
   616  		ChainID:                   1111,
   617  		Simulated:                 false,
   618  		ChainlinkTransactionLimit: 5000,
   619  		Timeout:                   blockchain.StrDuration{Duration: time.Minute},
   620  		MinimumConfirmations:      1,
   621  		GasEstimationBuffer:       0,
   622  		FinalityTag:               true,
   623  		DefaultGasLimit:           6000000,
   624  	}
   625  
   626  	FantomTestnet blockchain.EVMNetwork = blockchain.EVMNetwork{
   627  		Name:                      "Fantom Testnet",
   628  		SupportsEIP1559:           true,
   629  		ClientImplementation:      blockchain.FantomClientImplementation,
   630  		ChainID:                   4002,
   631  		Simulated:                 false,
   632  		ChainlinkTransactionLimit: 5000,
   633  		Timeout:                   blockchain.StrDuration{Duration: 3 * time.Minute},
   634  		MinimumConfirmations:      1,
   635  		GasEstimationBuffer:       1000,
   636  	}
   637  
   638  	FantomMainnet blockchain.EVMNetwork = blockchain.EVMNetwork{
   639  		Name:                      "Fantom Mainnet",
   640  		SupportsEIP1559:           true,
   641  		ClientImplementation:      blockchain.FantomClientImplementation,
   642  		ChainID:                   250,
   643  		Simulated:                 false,
   644  		ChainlinkTransactionLimit: 5000,
   645  		Timeout:                   blockchain.StrDuration{Duration: 3 * time.Minute},
   646  		MinimumConfirmations:      1,
   647  		GasEstimationBuffer:       1000,
   648  	}
   649  
   650  	KromaMainnet blockchain.EVMNetwork = blockchain.EVMNetwork{
   651  		Name:                      "Kroma Mainnet",
   652  		SupportsEIP1559:           true,
   653  		ClientImplementation:      blockchain.KromaClientImplementation,
   654  		ChainID:                   255,
   655  		Simulated:                 false,
   656  		ChainlinkTransactionLimit: 5000,
   657  		Timeout:                   blockchain.StrDuration{Duration: time.Minute},
   658  		MinimumConfirmations:      1,
   659  		GasEstimationBuffer:       1000,
   660  		FinalityTag:               true,
   661  		DefaultGasLimit:           6000000,
   662  	}
   663  
   664  	KromaSepolia blockchain.EVMNetwork = blockchain.EVMNetwork{
   665  		Name:                      "Kroma Sepolia",
   666  		SupportsEIP1559:           true,
   667  		ClientImplementation:      blockchain.KromaClientImplementation,
   668  		ChainID:                   2358,
   669  		Simulated:                 false,
   670  		ChainlinkTransactionLimit: 5000,
   671  		Timeout:                   blockchain.StrDuration{Duration: time.Minute},
   672  		MinimumConfirmations:      1,
   673  		GasEstimationBuffer:       1000,
   674  		FinalityTag:               true,
   675  		DefaultGasLimit:           6000000,
   676  	}
   677  
   678  	NexonDev blockchain.EVMNetwork = blockchain.EVMNetwork{
   679  		Name:                      "Nexon Dev",
   680  		SupportsEIP1559:           true,
   681  		ClientImplementation:      blockchain.EthereumClientImplementation,
   682  		ChainID:                   955081,
   683  		Simulated:                 false,
   684  		ChainlinkTransactionLimit: 5000,
   685  		Timeout:                   blockchain.StrDuration{Duration: time.Minute},
   686  		MinimumConfirmations:      0,
   687  		GasEstimationBuffer:       1000,
   688  		FinalityTag:               true,
   689  		DefaultGasLimit:           6000000,
   690  	}
   691  
   692  	NexonTest blockchain.EVMNetwork = blockchain.EVMNetwork{
   693  		Name:                      "Nexon Test",
   694  		SupportsEIP1559:           true,
   695  		ClientImplementation:      blockchain.EthereumClientImplementation,
   696  		ChainID:                   595581,
   697  		Simulated:                 false,
   698  		ChainlinkTransactionLimit: 5000,
   699  		Timeout:                   blockchain.StrDuration{Duration: time.Minute},
   700  		MinimumConfirmations:      0,
   701  		GasEstimationBuffer:       1000,
   702  		FinalityTag:               true,
   703  		DefaultGasLimit:           6000000,
   704  	}
   705  
   706  	NexonQa blockchain.EVMNetwork = blockchain.EVMNetwork{
   707  		Name:                      "Nexon Qa",
   708  		SupportsEIP1559:           true,
   709  		ClientImplementation:      blockchain.EthereumClientImplementation,
   710  		ChainID:                   807424,
   711  		Simulated:                 false,
   712  		ChainlinkTransactionLimit: 5000,
   713  		Timeout:                   blockchain.StrDuration{Duration: time.Minute},
   714  		MinimumConfirmations:      0,
   715  		GasEstimationBuffer:       1000,
   716  		FinalityTag:               true,
   717  		DefaultGasLimit:           6000000,
   718  	}
   719  
   720  	NexonStage blockchain.EVMNetwork = blockchain.EVMNetwork{
   721  		Name:                      "Nexon Stage",
   722  		SupportsEIP1559:           true,
   723  		ClientImplementation:      blockchain.EthereumClientImplementation,
   724  		ChainID:                   847799,
   725  		Simulated:                 false,
   726  		ChainlinkTransactionLimit: 5000,
   727  		Timeout:                   blockchain.StrDuration{Duration: time.Minute},
   728  		MinimumConfirmations:      0,
   729  		GasEstimationBuffer:       1000,
   730  		FinalityTag:               true,
   731  		DefaultGasLimit:           6000000,
   732  	}
   733  
   734  	GnosisChiado blockchain.EVMNetwork = blockchain.EVMNetwork{
   735  		Name:                      "Gnosis Chiado",
   736  		SupportsEIP1559:           true,
   737  		ClientImplementation:      blockchain.GnosisClientImplementation,
   738  		ChainID:                   10200,
   739  		Simulated:                 false,
   740  		ChainlinkTransactionLimit: 5000,
   741  		Timeout:                   blockchain.StrDuration{Duration: time.Minute},
   742  		MinimumConfirmations:      1,
   743  		GasEstimationBuffer:       1000,
   744  		FinalityTag:               true,
   745  		DefaultGasLimit:           6000000,
   746  	}
   747  
   748  	GnosisMainnet blockchain.EVMNetwork = blockchain.EVMNetwork{
   749  		Name:                      "Gnosis Mainnet",
   750  		SupportsEIP1559:           true,
   751  		ClientImplementation:      blockchain.GnosisClientImplementation,
   752  		ChainID:                   100,
   753  		Simulated:                 false,
   754  		ChainlinkTransactionLimit: 5000,
   755  		Timeout:                   blockchain.StrDuration{Duration: time.Minute},
   756  		MinimumConfirmations:      1,
   757  		GasEstimationBuffer:       1000,
   758  		FinalityTag:               true,
   759  		DefaultGasLimit:           6000000,
   760  	}
   761  
   762  	MappedNetworks = map[string]blockchain.EVMNetwork{
   763  		"SIMULATED":               SimulatedEVM,
   764  		"SIMULATED_1":             SimulatedEVMNonDev1,
   765  		"SIMULATED_2":             SimulatedEVMNonDev2,
   766  		"SIMULATED_BESU_NONDEV_1": SimulatedBesuNonDev1,
   767  		"SIMULATED_BESU_NONDEV_2": SimulatedBesuNonDev2,
   768  		"SIMULATED_NONDEV":        SimulatedEVMNonDev,
   769  		// "GENERAL":         generalEVM, // See above
   770  		"ETHEREUM_MAINNET":      EthereumMainnet,
   771  		"GOERLI":                GoerliTestnet,
   772  		"SEPOLIA":               SepoliaTestnet,
   773  		"KLAYTN_MAINNET":        KlaytnMainnet,
   774  		"KLAYTN_BAOBAB":         KlaytnBaobab,
   775  		"METIS_ANDROMEDA":       MetisAndromeda,
   776  		"METIS_STARDUST":        MetisStardust,
   777  		"ARBITRUM_MAINNET":      ArbitrumMainnet,
   778  		"ARBITRUM_GOERLI":       ArbitrumGoerli,
   779  		"ARBITRUM_SEPOLIA":      ArbitrumSepolia,
   780  		"OPTIMISM_MAINNET":      OptimismMainnet,
   781  		"OPTIMISM_GOERLI":       OptimismGoerli,
   782  		"OPTIMISM_SEPOLIA":      OptimismSepolia,
   783  		"BASE_GOERLI":           BaseGoerli,
   784  		"BASE_SEPOLIA":          BaseSepolia,
   785  		"CELO_ALFAJORES":        CeloAlfajores,
   786  		"CELO_MAINNET":          CeloMainnet,
   787  		"RSK":                   RSKTestnet,
   788  		"POLYGON_MUMBAI":        PolygonMumbai,
   789  		"POLYGON_MAINNET":       PolygonMainnet,
   790  		"AVALANCHE_FUJI":        AvalancheFuji,
   791  		"AVALANCHE_MAINNET":     AvalancheMainnet,
   792  		"QUORUM":                Quorum,
   793  		"SCROLL_SEPOLIA":        ScrollSepolia,
   794  		"SCROLL_MAINNET":        ScrollMainnet,
   795  		"BASE_MAINNET":          BaseMainnet,
   796  		"BSC_TESTNET":           BSCTestnet,
   797  		"BSC_MAINNET":           BSCMainnet,
   798  		"LINEA_GOERLI":          LineaGoerli,
   799  		"LINEA_MAINNET":         LineaMainnet,
   800  		"POLYGON_ZKEVM_GOERLI":  PolygonZkEvmGoerli,
   801  		"POLYGON_ZKEVM_CARDONA": PolygonZkEvmCardona,
   802  		"POLYGON_ZKEVM_MAINNET": PolygonZkEvmMainnet,
   803  		"FANTOM_TESTNET":        FantomTestnet,
   804  		"FANTOM_MAINNET":        FantomMainnet,
   805  		"WEMIX_TESTNET":         WeMixTestnet,
   806  		"WEMIX_MAINNET":         WeMixMainnet,
   807  		"KROMA_SEPOLIA":         KromaSepolia,
   808  		"KROMA_MAINNET":         KromaMainnet,
   809  		"NEXON_DEV":             NexonDev,
   810  		"NEXON_TEST":            NexonTest,
   811  		"NEXON_QA":              NexonQa,
   812  		"NEXON_STAGE":           NexonStage,
   813  		"GNOSIS_CHIADO":         GnosisChiado,
   814  		"GNOSIS_MAINNET":        GnosisMainnet,
   815  	}
   816  )
   817  
   818  // Get []blockchain.EVMNetwork from TOML config. Panic if no networks are found
   819  func MustGetSelectedNetworkConfig(networkCfg *config.NetworkConfig) []blockchain.EVMNetwork {
   820  	if networkCfg == nil || len(networkCfg.SelectedNetworks) == 0 {
   821  		panic(fmt.Errorf("network config has no or empty selected networks. Use valid network(s) separated by comma from %v", getValidNetworkKeys()))
   822  	}
   823  	nets, err := SetNetworks(*networkCfg)
   824  	if err != nil {
   825  		panic(err)
   826  	}
   827  	return nets
   828  }
   829  
   830  func SetNetworks(networkCfg config.NetworkConfig) ([]blockchain.EVMNetwork, error) {
   831  	networks := make([]blockchain.EVMNetwork, 0)
   832  	selectedNetworks := networkCfg.SelectedNetworks
   833  	for i := range selectedNetworks {
   834  		var walletKeys, httpUrls, wsUrls []string
   835  		networkName := strings.ToUpper(selectedNetworks[i])
   836  		forked := false
   837  		if networkCfg.ForkConfigs != nil {
   838  			_, forked = networkCfg.ForkConfigs[networkName]
   839  		}
   840  		// if network is not simulated or forked, use the rpc urls and wallet keys from config
   841  		if !strings.Contains(networkName, "SIMULATED") && !forked {
   842  			var ok bool
   843  			wsUrls, ok = networkCfg.RpcWsUrls[selectedNetworks[i]]
   844  			if !ok {
   845  				return nil, fmt.Errorf("no rpc ws urls found in config for '%s' network", selectedNetworks[i])
   846  			}
   847  
   848  			httpUrls, ok = networkCfg.RpcHttpUrls[selectedNetworks[i]]
   849  			if !ok {
   850  				return nil, fmt.Errorf("no rpc http urls found in config for '%s' network", selectedNetworks[i])
   851  			}
   852  
   853  			walletKeys, ok = networkCfg.WalletKeys[selectedNetworks[i]]
   854  			if !ok {
   855  				return nil, fmt.Errorf("no wallet keys found in config for '%s' network", selectedNetworks[i])
   856  			}
   857  		}
   858  		// if evm_network config is found, use it
   859  		if networkCfg.EVMNetworks != nil {
   860  			if network, ok := networkCfg.EVMNetworks[networkName]; ok && network != nil {
   861  				if err := NewEVMNetwork(network, walletKeys, httpUrls, wsUrls); err != nil {
   862  					return nil, err
   863  				}
   864  				networks = append(networks, *network)
   865  				continue
   866  			}
   867  		}
   868  		// if there is no evm_network config, use the known networks to find the network config from the map
   869  		if knownNetwork, valid := MappedNetworks[networkName]; valid {
   870  			err := NewEVMNetwork(&knownNetwork, walletKeys, httpUrls, wsUrls)
   871  			if err != nil {
   872  				return nil, err
   873  			}
   874  			networks = append(networks, knownNetwork)
   875  			continue
   876  		}
   877  		// if network is not found in known networks or in toml's evm_network config, throw an error
   878  		return nil, fmt.Errorf("no evm_network config found in network config. "+
   879  			"network '%s' is not a valid network. "+
   880  			"Use valid network(s) separated by comma from %v "+
   881  			"or add the evm_network details to the network config file",
   882  			selectedNetworks[i], getValidNetworkKeys())
   883  	}
   884  	return networks, nil
   885  }
   886  
   887  // NewEVMNetwork sets the network's private key(s) and rpc urls
   888  func NewEVMNetwork(network *blockchain.EVMNetwork, walletKeys, httpUrls, wsUrls []string) error {
   889  	if len(httpUrls) > 0 {
   890  		network.HTTPURLs = httpUrls
   891  	}
   892  	if len(wsUrls) > 0 {
   893  		network.URLs = wsUrls
   894  	}
   895  	if len(walletKeys) > 0 {
   896  		if err := setKeys(network, walletKeys); err != nil {
   897  			return err
   898  		}
   899  	}
   900  	return nil
   901  }
   902  
   903  func getValidNetworkKeys() []string {
   904  	validKeys := make([]string, 0)
   905  	for validNetwork := range MappedNetworks {
   906  		validKeys = append(validKeys, validNetwork)
   907  	}
   908  	return validKeys
   909  }
   910  
   911  // setKeys sets a network's private key(s) based on env vars
   912  func setKeys(network *blockchain.EVMNetwork, walletKeys []string) error {
   913  	for keyIndex := range walletKeys { // Sanitize keys of possible `0x` prefix
   914  		// Trim some common addons
   915  		walletKeys[keyIndex] = strings.Trim(walletKeys[keyIndex], "\"'")
   916  		walletKeys[keyIndex] = strings.TrimSpace(walletKeys[keyIndex])
   917  		walletKeys[keyIndex] = strings.TrimPrefix(walletKeys[keyIndex], "0x")
   918  	}
   919  	network.PrivateKeys = walletKeys
   920  
   921  	// log public keys for debugging
   922  	publicKeys := []string{}
   923  	for _, key := range network.PrivateKeys {
   924  		publicKey, err := privateKeyToAddress(key)
   925  		if err != nil {
   926  			return fmt.Errorf("error converting private key to public key: %w", err)
   927  		}
   928  		publicKeys = append(publicKeys, publicKey)
   929  	}
   930  	log.Info().Interface("Funding Addresses", publicKeys).Msg("Read Network Keys")
   931  	return nil
   932  }
   933  
   934  func privateKeyToAddress(privateKeyString string) (string, error) {
   935  	privateKey, err := crypto.HexToECDSA(privateKeyString)
   936  	if err != nil {
   937  		return "", err
   938  	}
   939  	publicKey := privateKey.Public()
   940  	publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey)
   941  	if !ok {
   942  		return "", fmt.Errorf("error casting private key to public ECDSA key")
   943  	}
   944  	return crypto.PubkeyToAddress(*publicKeyECDSA).Hex(), nil
   945  }