# 2. Setting up 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 no longer automatically 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). Calling refreshBalances is required to 'update' balances. Implementation of a polling system has now been passed onto the 'consumer wallet' to prevent any performance bottlenecks.&#x20;

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](/developer-guide/wallet/private-balances/balance-and-sync-callbacks.md) section.

We will discuss how to initiate additional merkletree scans to fetch latest private balances in the [Updating Balances](/developer-guide/wallet/private-balances/updating-balances.md) section.

To skip merkletree syncs, set `skipMerkletreeScans` to **true** in `startRailgunEngine` from Step 1.

```typescript
import { JsonRpcProvider, Wallet } from "ethers";
import { TEST_MNEMONIC, TEST_RPC_URL } from "./constants";

/**
 * Creates and returns a provider and wallet for JSON-RPC interactions.
 *
 * This utility function initializes a JSON-RPC provider with a test URL
 * and creates a wallet from a test mnemonic phrase. Both the provider
 * and wallet are returned as an object.
 *
 * @returns An object containing the initialized provider and wallet
 * @property {JsonRpcProvider} provider - The JSON-RPC provider instance
 * @property {Wallet} wallet - The wallet instance created from the test mnemonic
 *
 * @example
 * const { provider, wallet } = getProviderWallet();
 * // Now use provider for RPC calls and wallet for signing transactions
 */
export const getProviderWallet = () => {
  const provider = new JsonRpcProvider(TEST_RPC_URL);
  const wallet = Wallet.fromPhrase(TEST_MNEMONIC, provider);

  return {
    provider,
    wallet,
  };
};
```

The return value, `feesSerialized`, contains the following fields:&#x20;

* `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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.railgun.org/developer-guide/wallet/getting-started/2.-setting-up-networks-and-rpc-providers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
