Solana
Solana tool suite
-
Install the Solana tool suite. See Install the Solana Tool Suite.
-
Connect the Solana tool suite to the Chainstack-deployed Solana node:
solana config set --url YOUR_CHAINSTACK_ENDPOINT
where YOUR_CHAINSTACK_ENDPOINT is your node HTTPS or WSS endpoint protected either with the key or password. See node access details.
-
Run the Solana client commands.
Example to get the block height:
$ solana block-height 106318062
WebSocket endpoint
When you set the HTTPS endpoint with
solana config set
, the tool will also set a computed WebSocket endpoint, which is incorrect.To use WebSocket, you must set the WebSocket explicitly with
--ws
.Example:
solana config set --ws YOUR_CHAINSTACK_WSS_ENDPOINT
JSON-RPC API
Interact with your Solana network using JSON-RPC API.
Example to get account balance:
curl -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"getBalance","params":["23dQfKhhsZ9RA5AAn12KGk21MB784PmTB3gfKRwdBNHr"],"id":1}' \
YOUR_CHAINSTACK_ENDPOINT
where YOUR_CHAINSTACK_ENDPOINT is your node HTTPS or WSS endpoint protected either with the key or password. See node access details.
Solana web3.js
-
Install Solana web3.js. See Solana web3.js guide.
-
Use
Connection
to connect to your Solana node and get account balance:const web3 = require("@solana/web3.js"); (async () => { const publicKey = new web3.PublicKey( '23dQfKhhsZ9RA5AAn12KGk21MB784PmTB3gfKRwdBNHr' ); const connect = new web3.Connection('YOUR_CHAINSTACK_ENDPOINT'); console.log(await connect.getBalance(publicKey)); })();
where YOUR_CHAINSTACK_ENDPOINT is your node HTTPS or WSS endpoint protected either with the key or password. See node access details.
Solana.py
-
Install Solana.py.
-
Use
Client
to connect to your Solana node and get account balance:from solana.rpc.api import Client from solana.publickey import PublicKey client = Client('YOUR_CHAINSTACK_ENDPOINT') print(client.get_balance(PublicKey('23dQfKhhsZ9RA5AAn12KGk21MB784PmTB3gfKRwdBNHr')))
where YOUR_CHAINSTACK_ENDPOINT is your node HTTPS or WSS endpoint protected either with the key or password. See node access details.
Backpack wallet
Backpack is one of the few (if not the only) Solana wallets allowing to add a custom RPC node endpoint.
You should use your own Solana RPC node for enterprise-grade reliability, not to fall victim to a sudden network congestion, or if you want to use your own Trader node .
To add your own Solana RPC node endpoint to your Backpack wallet:
- Open your Backpack wallet.
- Click the account icon > Settings.
- Click Solana > RPC connection > Custom.
- Enter your Chainstack Solana node endpoint and hit Update.
Congrats, now you are safe with reliable network access.
Updated about 2 months ago