4. Add networks and RPC providers
Next, you will need to load an RPC provider for each network/chain that you intend to run private transactions on.
The loadProvider
function loads the RailgunProxyContract & RelayAdaptContract and returns the RAILGUN fees for the provided network.
Additionally, it kicks off a merkletree balance scan. This is necessary to know the private balances of the available RAILGUN wallets in the local database (set up in Step 1).
We will set up an onMerkletreeScanCallback
function (to monitor the scan's progress and status) and an onBalanceUpdateCallback
function (to get notifications of the private balances of each available wallet) in the Balance and Sync Callbacks section.
We will discuss how to initiate additional merkletree scans to fetch latest private balances in the Updating Balances section.
To skip merkletree syncs, set skipMerkletreeScans
to true in startRailgunEngine
from Step 1.
Example: Load Ethereum network
The return value, feesSerialized
, contains the following fields:
deposit
: hex string, representing shielding fee in basis points. Current default is 25bp (0.25% fee).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 0bp.
Store these to inform the user of the RAILGUN fee associated with their transaction.
Last updated