Skip to content
EthNews

News from across Ethereum

MetaMask’s Add-Before-Switch Network Flow

Why does MetaMask ask to add a network before switching? MetaMask needs the chain ID and RPC endpoint saved before it can select that chain as active.

The EthNews Desk4 min read

MetaMask’s Add-Before-Switch Network Flow

MetaMask asks to add a network before switching when a dApp requests an EVM chain that the wallet has not saved; the wallet needs that chain’s ID and RPC endpoint before it can direct requests there.

Adding saves a chain; switching selects it

Adding and switching are separate wallet actions. A dApp can request a network using wallet_addEthereumChain, which asks MetaMask to save its chain configuration. It can request wallet_switchEthereumChain to make a saved chain active.

Those requests solve different parts of the connection. A Chain ID identifies the EVM chain, and an RPC endpoint gives the wallet a destination for JSON-RPC requests. Chainlist records network details that help users connect wallets and dApps. Its network entries can also help explain Chainlist’s add-before-switch flow: a chain needs to be available to the wallet before a request can select it.

Say you open a dApp that needs a particular test network. If MetaMask has not saved that network, the dApp may first request that the wallet add it. MetaMask shows the requested details for your review. If you approve, the network is saved. The dApp can then request a switch to it, and MetaMask asks you to approve that change too.

Before the first approval, the network is absent from MetaMask’s saved networks, so the wallet has no configuration for it. After adding, the configuration is saved, but the active chain may still be the one you were using. After switching, the newly added chain is active, allowing the dApp’s requests to use it. The saved network remains available for later sessions.

Review the requested network before adding it

The add prompt is a request to save network details, so compare those details with the network you intend to use. Review the chain name, Chain ID, RPC endpoint, native currency and explorer details if MetaMask displays them.

Chainlist can help you find a network entry and its published connection details. Treat the entry as a reference for the prompt: compare the values rather than approving based only on a familiar network name. The name is useful for recognition, while the Chain ID and RPC endpoint are the key configuration values involved in identifying and reaching the chain.

Take an illustrative case: you select a network in Chainlist, then a dApp requests it in MetaMask. The add prompt shows a chain name and ID, an RPC endpoint, a currency and an explorer. If those details match the network you meant to use, approving adds its configuration to the wallet. If a detail differs from the source you trust or from the network you intended, decline and confirm the correct values before proceeding.

Once the network is saved, a later dApp request may need only a switch approval. In practice, this happens when the wallet already has the chain configuration but another chain is currently active. MetaMask can then ask to change the active chain without asking to add the network again.

The add-then-switch sequence can therefore be expected: the first prompt saves the missing configuration, and the second selects it for the dApp. Approving the add prompt does not, by itself, mean the requested chain is now active. The switch prompt is the action that changes which saved chain MetaMask is using.

Related questions

Does adding a network to MetaMask switch to it?

Adding a network saves its configuration; it does not necessarily make that network active. MetaMask may show a separate switch request afterward. If the dApp requests the switch and you approve it, the wallet selects that saved chain as active.

Why does MetaMask say the network is already added?

MetaMask says a network is already added when its configuration is already saved in the wallet. The dApp may still request a switch because the active chain is different. Review the switch request and confirm that it names the network you intend to use.

When the prompt is to add, review the network details and approve only if they match your intended chain; when the network is already saved, decide whether to approve the switch to make it active.