Marketplace has launched, further enabling blockchain developers! Learn more

How to add Custom RPC to Phantom and Solflare

September 23, 2022

Overview

Using a non-custodial wallet is a necessity when interacting with web3 dApps. Phantom and Solflare are the most widely used Solana non-custodial wallets.

Most non-custodial wallets (including Phantom and Solflare) come with default RPC nodes set up. Using these wallets with default networks is acceptable for the majority of applications most of the time. However, suppose the operations you are performing require transactions to reach the chain faster or updating a balance where the latest information is crucial - in that case, a fast, reliable RPC node can come in handy. Sometimes the nodes behind these wallets may experience some downtime or lag as these wallets are public and a lot of people are accessing them at the same time. During such times, having a custom RPC node can come in handy.

What You Will Do
In this guide, we will see how to add a custom RPC to Phantom and Solflare.

What You Will Need
  • Nodejs installed (version 16.15 or higher)
  • Phantom Wallet or Solflare extension installed
  • HTTP Proxy installed
  • A text editor
  • npm or yarn installed (We will be using npm to initialize our project and install the necessary packages. Feel free to use yarn instead if that’s your preferred package manager)

Booting a Solana Node

The purpose of setting up a custom RPC in these wallets is to have a fast, reliable RPC node behind the wallet, which is why we will use QuickNode for this. So just grab a free QuickNode and head over to the next step.

Screenshot of QuickNode dash


You'll need the HTTP Provider link later, so copy it and save it.

Adding Solana Node to Phantom and Solflare

Now that we have a QuickNode Solana RPC, let us use it to power our wallets:

Phantom

Step 1: Go to your Phantom wallet and click on the settings icon on the bottom right. Then scroll down and click on 'Change Network'.

Screenshot of Phantom wallet 1
Screenshot of Phantom wallet 2


Step 2: Select the fourth option, 'Localhost,' and return to the wallet home screen. Now, you must see a message 'Failed to get assets' because we still have not set up our RPC to work with Phantom.

Screenshot of Phantom wallet 3
Screenshot of Phantom wallet 4


Step 3: Currently, there is no way to add a custom RPC in Phantom directly, so we will use a Node.js proxy server to listen to a port that Phantom wallet listens on and resolve to our QuickNode RPC.

First, make a directory and install http-proxy using npm(Node Package Manager), which comes with Node.js:

adding solana node to phantom and solflare

Copy
mkdir proxy_server
cd proxy_server

Installing http-proxy:

adding solana node to phantom and solflare

Copy
npm i http-proxy

Now, create a server.js file in the directory and copy-paste the following code snippet into it:

adding solana node to phantom and solflare

Copy
var http = require('http'),
    httpProxy = require('http-proxy');

httpProxy.createProxyServer({target:'ADD_YOUR_QUICKNODE_HTTPS_URL_HERE', changeOrigin:true}).listen(8899);
console.log("listening on: 8899");

Replace ADD_YOUR_QUICKNODE_HTTPS_URL_HERE with your QuickNode Solana node's HTTP Provider URL we got in the previous step and save the file.

Explanation of the code above:

Lines 1-2: Importing http and http-proxy packages/libraries.
Line 3: Creating a proxy server to listen on localhost port number 8899 and resolving to our QuickNode Solana node.
Line 4: Printing a text when the server is listening.

Now, run the file by entering the following in your terminal:

adding solana node to phantom and solflare

Copy
node server

Open your Phantom wallet, and now it should load all your assets successfully with a banner on top saying, "You are currently on Localhost".

Screenshot of Phantom wallet 5

Congrats! You have connected your Phantom Wallet to your QuickNode HTTP Endpoint. Now, let's configure Solflare.

Solflare

Step 1: Go to your Solflare wallet and click on the setting logo on the bottom right. Then click on Network.

Screenshot of Solflare wallet 1
Screenshot of Solflare wallet 2


Step 2: Click on ADD CUSTOM NODE. Enter a name for your node (QuickNode RPC in this example) and then paste your QuickNode Solana Node's RPC URL in the second field. Click Save and then click Proceed. Your QuickNode RPC is set up in Solflare now.

Screenshot of Solflare wallet 3

Conclusion

In this tutorial, we learned about setting up custom RPC in Phantom and Solflare wallets. To learn more, check out some of our other Solana tutorials or subscribe to our newsletter.

We ❤️ Feedback! If you have any feedback or questions on this guide, please let us know.

Also, feel free to reach out to us via Twitter or our Discord community server. We’d love to hear from you!

Related articles 33

Como crear un NFT en SOLANA
Published: Dec 27, 2021
Updated: Sep 23, 2022

¡Hola querido lector! Bienvenidos a una nueva guía de Solana.Solana es una blockchain que promete mucho a la hora de intentar resolver los problemas de escalabilidad que...

Continue reading
How to Get Transaction Logs on Solana
Published: Jun 24, 2022
Updated: Oct 27, 2022

Ever need to pull all the transactions associated with a Wallet? Want to see all of the mint transactions associated with a Candy Machine? Or maybe see transaction history of an NFT? Solana's...

Continue reading
How to Transfer SPL Tokens on Solana
Published: Sep 23, 2022
Updated: Sep 23, 2022

Sending Solana Program Library (SPL) Tokens is a critical mechanism for Solana development. Whether you are airdropping whitelist tokens to your community, bulk sending NFTs to another wallet,...

Continue reading
How to Mint an NFT on Solana
Published: Aug 27, 2021
Updated: Sep 23, 2022

Updated at: April 10, 2022Welcome to another QuickNode guide on Solana - the up-and-coming blockchain that seeks to solve the scalability issues of Ethereum. We will be walking through...

Continue reading
How to Send Bulk Transactions on Solana
Published: Aug 31, 2022
Updated: Oct 3, 2022

Are you running a batch process that has many transactions? Perhaps an airdrop to your community's NFT holders or a token distribution to early users of your dApp. Solana transaction...

Continue reading
Solana Fundamentals Reference Guide
Published: Oct 27, 2022
Updated: Oct 27, 2022

The Solana blockchain is a powerful tool, delivering thousands of transactions per second with almost no-cost transaction fees. If you are new to Web3 or have developed on EVM-based...

Continue reading