Solana

Solana tool suite

  1. Install the Solana tool suite. See Install the Solana Tool Suite.

  2. 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.

  3. 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.

Use curl or Postman.

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

  1. Install Solana web3.js. See Solana web3.js guide.

  2. 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

  1. Install Solana.py.

  2. 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:

  1. Open your Backpack wallet.
  2. Click the account icon > Settings.
  3. Click Solana > RPC connection > Custom.
  4. Enter your Chainstack Solana node endpoint and hit Update.

Congrats, now you are safe with reliable network access.