4. Add networks and RPC providers

Next, you will need to load a provider for each network/chain that you intend to run private transactions on.
This action loads RailgunProxyContract and RelayAdaptContract for the chain, and returns the current fees for the current network.
It also kicks off a merkletree balance sync, which calls onBalanceUpdateCallback for each available wallet when finished. To skip merkletree syncs, set skipMerkletreeScans to true during startRailgunEngine.

Example: Load Ethereum network

import {
FallbackProviderJsonConfig,
NetworkName,
} from '@railgun-community/shared-models';
import { loadProvider } from '@railgun-community/wallet';
​
const ETH_PROVIDERS_JSON: FallbackProviderJsonConfig = {
"chainId": 1,
"providers": [
{
"provider": "https://cloudflare-eth.com/",
"priority": 1,
"weight": 1
},
{
"provider": "https://rpc.ankr.com/eth",
"priority": 2,
"weight": 1
}
]
}
​
const shouldDebug = true;
​
const { feesSerialized } = await loadProvider(
ETH_PROVIDERS_JSON,
NetworkName.Ethereum,
shouldDebug,
);
The return value, feesSerialized, contains the following fields:
  • deposit: hex string, representing shielding fee in basis points (current default is 25bp)
  • withdraw: hex string, representing unshielding fee in basis points (current default is 25bp)
  • nft: hex string, representing fee for NFT shielding/unshielding (current default is 0)