ethers-io / ethers.js

Complete Ethereum library and wallet implementation in JavaScript.
https://ethers.org/
MIT License
7.89k stars 1.82k forks source link

Avalanche Mainnet/Fuji Infura support #3641

Open charlie-kim opened 1 year ago

charlie-kim commented 1 year ago

Describe the Feature

Similar to https://github.com/ethers-io/ethers.js/issues/3323, creating a InfuraProvider instance with chain ID 43114(mainnet), 43113(fuji testnet) generates unsupported network error.

{
  reason: 'unsupported network',
  code: 'INVALID_ARGUMENT',
  argument: 'network',
  value: { chainId: 43114, name: 'unknown' }
}

Code Example

new ethers.providers.InfuraProvider(43114, {
  projectId: infuraProjectId,
  projectSecret: infuraProjectSecret,
})
woosal1337 commented 1 year ago

This is still WIP. Any estimated time for it to be completed?

0x7An commented 5 months ago

@charlie-kim @woosal1337 To bypass the 'unsupported network' error with Avalanche networks, switch to using ethers.JsonRpcProvider with your network's RPC URL.

ricmoo commented 5 months ago

Is Avalanche json-rpc compatible with Ethereum?

For some reason I thought it wasn’t. But if it is, I can add it to the InfuraProvider.

0x7An commented 5 months ago

@ricmoo Looks like only C-Chain is compatible.

https://docs.infura.io/api/networks/avalanche-c-chain/json-rpc-methods

charlie-kim commented 5 months ago

@charlie-kim @woosal1337 To bypass the 'unsupported network' error with Avalanche networks, switch to using ethers.JsonRpcProvider with your network's RPC URL.

Thanks. But ethers.JsonRpcProvider makes extra request to get chain ID. It will be better to use ethers. InfuraProvider.

charlie-kim commented 3 months ago

@ricmoo any update on this, please?