Essential RPC Concepts for dApp Connectivity

Created by:

Avatar

john-mac.eth @ @GeorgeMac510

August 15, 2022

Twitter @GeorgeMac510

RPCs

Remote Procedure Call (RPC) could be classified as a type of API (application programming interface) that allows for developers to run code that can be executed on servers remotely. In plain English, an RPC call is how a dApp communicates with the blockchain or accesses other information from remote servers. In this section, we will concern ourselves with RPC calls to the blockchain via Metamask to Ethereum testnets such as Ropsten and RPC endpoint providers such as Infura, Alchemy, Chainstack, and Ankr.

Connecting to a Testnet with Metamask

When opening up the Metamask browser extension, we can connect to the various testnets by clicking on the pull-down menu as seen below and chose your desired testnet network:

Ropsten Test Network

If you are trying to view a given network’s RPC connection information or add a network, it can be accessed in the Metamask extension by clicking on the Hamburger(round multi-color icon above) > Settings > Networks. In my case, I am connected to the Ropsten testnet, so its Network Name, RPC URL, Chain ID, Currency Symbol, and Block Explorer URL are shown below:

Ropsten RPC Metamask

Add a Network

A new network can be added in Metamask by clicking on the Add a network button and adding the 5 data inputs seen in the image above given in your tutorial or other source.

Connecting a dApp through an RPC Endpoint Provider

In blockchain development, it is necessary to connect your dApp to the blockchain to deploy smart contracts and interact with the deployed contract. This can be done by either running your own blockchain node such as GETH or accessing the blockchain through an RPC endpoint service such as Infura, Alchemy, Chainstack, Ankr, etc. Connecting through node providers is much easier than running your own node.

By using a node provider, it is quick, easy and FREE to open an account and get access to RPC endpoints of many different testnets including Sepolia Ethereum, Polygon Mumbai, Optimism Kovan and Solana Devnet. The websites for the aforementioned RPC endpoint providers can be found below:

IT IS SUPER IMPORTANT TO ALWAYS DOUBLE-CHECK THE WEBSITE URL YOU ARE CLICKING ON AND THE POP-UP MESSAGE IN METAMASK WHEN CONNECTING YOUR WALLET. IF YOU ARE ON THE WRONG WEBSITE AND YOU ALLOW ACCESS TO YOUR METAMASK WALLET, YOU MAY BE ALLOWING HACKERS ACCESS TO YOUR WALLET. BE SAFE!! ALWAYS DOUBLE-CHECK!!