# wallet\_addNetwork

## Add a custom to the user's Xverse wallet&#x20;

The `wallet_addNetwork` method prompts the user to add a custom network to their Xverse Wallet.&#x20;

This method allows dApps to onboard users to a **custom network** (typically for **Regtest** or staging environments) without requiring manual wallet setup.

The app must have first [connected to the wallet](https://docs.xverse.app/sats-connect/connecting-to-the-wallet/connect-to-xverse-wallet) and obtained [account read permissions.](https://docs.xverse.app/sats-connect/xverse-wallet-permissions)&#x20;

{% hint style="info" %}
You can fetch the networks that the user's wallet is currently connected to, using [`wallet_getNetwork`](https://docs.xverse.app/sats-connect/wallet-methods/wallet_getnetwork).&#x20;
{% endhint %}

### Parameters

<table><thead><tr><th width="270">Request parameters</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td>a string representing the user-visible network label (e.g. <code>"my-custom-regtest"</code>)</td></tr><tr><td><code>chain</code></td><td>Currently only <code>"bitcoin"</code> is supported, to add custom <a href="https://developer.bitcoin.org/examples/testing.html#regtest-mode">Regtest</a> networks</td></tr><tr><td><code>rpcUrl</code></td><td>a string representing the main RPC JSON-RPC endpoint for the added network</td></tr><tr><td><code>rpcFallbackUrl</code><br><span data-gb-custom-inline data-tag="emoji" data-code="2139">ℹ️</span> Optional</td><td>a string representing the fallback RPC URL if primary fails</td></tr><tr><td><code>indexerUrl</code><br><span data-gb-custom-inline data-tag="emoji" data-code="2139">ℹ️</span> Optional</td><td>a string representing the Indexer API used for advanced indexing of the balances and transaction history on the added network</td></tr><tr><td><code>blockExplorerUrl</code><br><span data-gb-custom-inline data-tag="emoji" data-code="2139">ℹ️</span> Optional</td><td>a string representing the transaction explorer base URL for the added network</td></tr></tbody></table>

```typescript
import Wallet from 'sats-connect';

async function example() {
  const res = await Wallet.request('wallet_addNetwork', {
   name: 'my-custom-regtest',
   chain: 'bitcoin',
   rpc_url: 'https://custom-regtest.tech/api/proxy',
   indexer_api: 'https://indexer.my-custom-regtest.app',
   block_explorer_url: 'https://mempool-my-custom-regtest.space',
   rpc_fallback_url: 'https://fallback.custom-regtest.tech/api/proxy' // optional
  });
  if (res.status === 'error') {
    console.error(res.error);
    return;
  }

  console.log(res.result);
}
```

## :white\_check\_mark: addNetwork Result&#x20;

The method will&#x20;

* prompt the user to add the custom network to their Xverse wallet![](https://3630714736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F33DLypUqgcjkBSmN0gZn%2Fuploads%2FABBBCGcZVOBiItKWlMOc%2Fimage.png?alt=media\&token=8fdb43a9-214c-4c66-add0-8a6784bf7665)
* return `null` if the user accepts the prompt and adds the network -> **Null response**

The addition of the network to the wallet will emit a [networkAdded](https://docs.xverse.app/sats-connect/xverse-wallet-events#networkadded-event) event which your app can catch.

{% hint style="info" %}
Your app can then&#x20;

* prompt the user to switch their Xverse wallet to the newly added network with the [wallet\_changeNetwork](https://docs.xverse.app/sats-connect/wallet-methods/wallet_changenetwork)
* &#x20;fetch the user's active Xverse account under the new network with the [`wallet_getAccount`](https://docs.xverse.app/sats-connect/wallet-methods/wallet_getaccount) method.
  {% endhint %}
