0%
Overview page background
HomeOverviewsInfra
How to Setup an Alternative RPC

How to Setup an Alternative RPC

Alchemy headshot

Written by Alchemy

Brady Werkheiser headshot

Reviewed by Brady Werkheiser

Published on August 10, 20224 min read

A remote procedure call (RPC) is a technique in which software is able to remotely communicate with other systems on the same network to access software or data. In the RPC methodology, a client requests something (e.g. data) and a server fills the request remotely. 

In blockchain, this technology has been adapted in the form of RPC nodes, an API in which blockchain developers can interact with blockchain servers (i.e. nodes). As a result, blockchain developers have the capability to create web3 software like dApps that necessitate RPC nodes to link to the blockchain.

In this article, we’re going to explain the importance of using a blockchain node provider and configuring an alternative RPC endpoint as well as the various reasons why an alternative or backup RPC endpoint is important.

Furthermore, we’ll walk you through the different methods of setting up an alternative RPC endpoint in case you want to integrate alternative RPC endpoints into your current blockchain project.

An alternative remote procedure call (RPC) endpoint is a backup endpoint for when the primary RPC endpoint fails or goes down. The risk of an RPC endpoint failure can mean the failure of 1000s or potentially millions of transactions failing.

As a solution, developers have begun to look for backup plans in the event that the primary RPC endpoint fails. One solution is to set up alternative RPC endpoints which act as a fail safe in the event that a primary RPC endpoint fails to function properly.

An alternate RPC endpoint is similar to a private RPC endpoint which is a dedicated endpoint for an application or wallet, but it is different in it's implementation. An alternate RPC endpoint refers to a backup, whereas a private RPC endpoint simply means a non-public endpoint.

Alternative RPC endpoints have a variety of potential use cases for blockchain developers ranging from public RPC endpoints being unreliable, to fixing common transaction problems like inaccurate data. In this section, we’ll tackle some of the common situations in which alternative RPC endpoints may be useful.

One of the primary use cases of setting up an alternative RPC endpoint is as a backup option in case the primary RPC is completely down, leading to a loss of connection between blockchain-enabled software and the blockchain. This can lead to the temporary malfunction of blockchain-powered software if an RPC alternative is not immediately available.

For example, in July of 2022, there was a network-wide failure of Polygon's public RPC endpoint hosted by Ankr, and the Chief Information Security Officer (CISO), Mudit Gupta, recommended using an alternative Polygon RPC provider like Alchemy that was not experiencing downtime.

Polygon recommended switching to Alchemy when the public RPC provider, Ankr, was hijacked in July, 2022.
Polygon recommended switching to Alchemy when the public RPC provider, Ankr, was hijacked in July, 2022.

Another important application of alternative RPC endpoints is a backup option in case the primary RPC endpoint is congested or slow, leading to delayed transactions. This can be particularly disastrous for dApps which heavily rely on instantaneous communication with the blockchain.

When transactions fail, using an alternative RPC endpoint can be a good backup option to ensure the web3 user experience isn't negatively impacted by unstable nodes.

Because blockchains are globally distributed systems, some node providers return inaccurate data from the blockchain because their network of nodes is out of sync with the public blockchain.

When a node provider's fleet of servers are out of sync, it leads to the users receiving inaccurate data such as inaccurate balances, missing NFTs, and overall a poor user experience.

In this situation, having alternative RPC endpoints integrated in your blockchain application means having the option to easily switch from your primary node provider to a secondary, fallback node provider to avoid returning inaccurate data.

Lastly, alternative RPC endpoints can be useful when your primary RPC endpoint has scalability challenges during times of high traffic such as a token airdrop, high profile NFT drop, or incentivized on-chain activity.

As a result, an alternative RPC endpoint can be used to offset the high traffic in order to avoid the primary RPC endpoint from collapsing under the scalability stress.

When you're dealing with a faulty RPC endpoint, there are three main ways to try to resolve the situation: retrying the transaction on the same endpoint, cycling transactions between a list of RPC endpoints, or changing your primary RPC provider.

One approach to dealing with faulty RPC endpoints is sending additional requests to the same RPC endpoint. In this methodology, developers will repeatedly send requests to the same RPC endpoint using a small delay between each retry. This technique works best when a RPC endpoint may temporarily be down for a small period of time, allowing developers to send requests until that RPC endpoint is back online.

Another approach is to connect to one or more alternative RPC endpoints and sending a series of RPC requests between a list of different RPC endpoints. In this technique, developers can avoid the issue of having a singular faulty RPC endpoint ruin their blockchain application by having multiple options to retry transactions with instead of retrying the same transaction on the same endpoint.

In the event of a faulty RPC endpoint, developers that use a list of alternative RPC providers can simply connect to a different endpoint on their approved list. 

Because setting up a list of alternative RPC endpoints can be challenging, a simpler option, depending on how your application is built, is to switch out your primary RPC endpoint with a more reliable backup provider such as Alchemy.

In this approach, instead of cycling through multiple different endpoints, or retrying transactions on the same endpoint, you can replace your RPC endpoint URL with a reliable backup entirely.

Overview cards background graphic
Desktop section background image

Build blockchain magic

Alchemy combines the most powerful web3 developer products and tools with resources, community and legendary support.

Get your API key