@@ -48,7 +48,7 @@ An array of Chains that your app supports:
48
48
type Chain = {
49
49
id: ChainId // hex encoded string, eg '0x1' for Ethereum Mainnet
50
50
namespace? : ' evm' // string indicating chain namespace. Defaults to 'evm' but will allow other chain namespaces in the future
51
- rpcUrl: string // used for network requests
51
+ rpcUrl: string // used for network requests (eg Alchemy or Infura end point)
52
52
label: string // used for display, eg Ethereum Mainnet
53
53
token: TokenSymbol // the native token symbol, eg ETH, BNB, MATIC
54
54
color? : string // the color used to represent the chain and will be used as a background for the icon
@@ -251,26 +251,31 @@ import injectedModule from '@web3-onboard/injected-wallets'
251
251
252
252
const injected = injectedModule ()
253
253
254
+ // Only one RPC endpoint required per chain
255
+ const ETH_MAINNET_RPC = ` https://mainnet.infura.io/v3/${ INFURA_KEY } ` || ` https://eth-mainnet.g.alchemy.com/v2/${ ALCHEMY_KEY } `
256
+ const ETH_ROPSTEN_RPC = ` https://ropsten.infura.io/v3/${ INFURA_ID } ` || ` https://eth-ropsten.g.alchemy.com/v2/${ ALCHEMY_KEY } `
257
+ const ETH_RINKEBY_RPC = ` https://rinkeby.infura.io/v3/${ INFURA_KEY } ` || ` https://eth-rinkeby.g.alchemy.com/v2/${ ALCHEMY_KEY } `
258
+
254
259
const onboard = Onboard ({
255
260
wallets: [injected],
256
261
chains: [
257
262
{
258
263
id: ' 0x1' ,
259
264
token: ' ETH' ,
260
265
label: ' Ethereum Mainnet' ,
261
- rpcUrl: ` https://mainnet.infura.io/v3/ ${ INFURA_ID } `
266
+ rpcUrl: ETH_MAINNET_RPC
262
267
},
263
268
{
264
269
id: ' 0x3' ,
265
270
token: ' tROP' ,
266
271
label: ' Ethereum Ropsten Testnet' ,
267
- rpcUrl: ` https://ropsten.infura.io/v3/ ${ INFURA_ID } `
272
+ rpcUrl: ETH_ROPSTEN_RPC
268
273
},
269
274
{
270
275
id: ' 0x4' ,
271
276
token: ' rETH' ,
272
277
label: ' Ethereum Rinkeby Testnet' ,
273
- rpcUrl: ` https://rinkeby.infura.io/v3/ ${ INFURA_ID } `
278
+ rpcUrl: ETH_RINKEBY_RPC
274
279
},
275
280
{
276
281
id: ' 0x38' ,
@@ -580,7 +585,8 @@ const onboard = Onboard({
580
585
id: ' 0x1' ,
581
586
token: ' ETH' ,
582
587
label: ' Ethereum Mainnet' ,
583
- rpcUrl: ` https://mainnet.infura.io/v3/${INFURA_ID } `
588
+ // Only one RPC required
589
+ rpcUrl: ` https://mainnet.infura.io/v3/${INFURA_KEY } ` || ` https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY } `
584
590
}
585
591
]
586
592
})
0 commit comments