Force One Blockchain Network on Web3 App

Shmoji
5 min readJun 9, 2022

A common pattern in web3 apps is to force the user to only have access to your website when they are on the correct blockchain network. Otherwise, the app doesn’t work. If the developer created the app environment to work for the Ethereum Mainnet network, then it won’t work on Ethereum testnet.

Technically, you could write code to handle both networks at the same time, but that doesn’t make much sense for mainnet and testnet. So, it becomes obvious why developers would enforce only one network on their frontend and this tutorial shows exactly how to do that.

Resources for this tutorial:

First things first, your app needs the ability to connect to user wallets. I use web3-react for that in all my apps. This tutorial shows how to set that up:

Once users can connect their wallet to your app, you now gain access to some important…

--

--