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.
Updated 6 months ago