npm install @web3-systems/multichain-providers
yarn add @web3-systems/multichain-providers
git clone https://github.com/web3-systems/multichain-providers
The MultichainProvider class wraps the @ethersproject/providers
Provider
class.
Updating function signatures with chainId
to specify a target network.
Example
provider.getBalance('0x000.0000')
is now...
multiprovider.getBalance('0x000.0000', 1);
The function signature (as you can see) now consumes chainId
in the first argument position. If a provider has been configured for the chainId the provider will be used when fetching the balance.
import { MultichainProviders } from '@web3-systems/multichain-providers';
let client = new MultichainProviders(); // by default connect to Ethereum mainnet via Infura
let jsonRpcURL = 'localhost:8545'
client.connect(1, jsonRpcURL); // sets chainId to use localhost as the endpoint
import { BigNumber } from '@ethersproject/bignumber';
import { MultichainProviders } from '@web3-systems/multichain-providers';
const client = new MultichainProviders();
const balance:BigNumber = await client.getBalance('0x000...000', 1);
import { Provider } from '@ethersproject/providers';
import { MultichainProviders } from '@web3-systems/multichain-providers';
const client = new MultichainProviders();
const provider:Provider = await client.getProvider(1);
import { Transactions } from '@ethersproject/contracts';
import { MultichainProviders } from '@web3-systems/multichain-providers';
let apikey = 'etherscan/polygonscan/snowtrace-apikey'
let client = new MultichainProviders(1, apikey, 'chainscan');
const transactions: Transactions[] = await client.getTransactions('0x000...000', 1);
Coming soon...
Utility functions like getTransactions
(specific to Etherscan) and getLogsDecoded
have been included to simplify common method chaining and developer objectives.
For example, instead of fetching event logs and decoding separately, a single function can be called.
const events = await client.getLogsDecoded(1,filter,contract,fragment);
/*
[
{
log: {...},
parsed: {...}
},
{
log: {...},
parsed: {...}
},
]
*/
The package is setup using the TSDX zero-config CLI which includes:
Generated using TypeDoc