# Tools

# Solana tool suite

  1. Install the Solana tool suite. See Install the Solana Tool Suite (opens new window).
  2. Connect the Solana tool suite to the Chainstack-deployed Solana node:
solana config set --url HTTPS_ENDPOINT

where HTTPS_ENDPOINT is your node HTTPS endpoint. See also View node access and credentials.

Example:

  • Key-protected
  • Password-protected
solana config set --url https://nd-123-456-789.p2pify.com/3c6e0b8a9c15224a8228b9a98ca1531d
  1. Run the Solana client commands (opens new window).

Example to get the block height:

$ solana block-height
106318062

TIP

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 wss://ws-nd-123-456-789.p2pify.com/3c6e0b8a9c15224a8228b9a98ca1531d

# JSON-RPC API

Interact with your Solana network using JSON-RPC API (opens new window).

Use curl (opens new window) or Postman (opens new window).

Example to get account balance:

  • Key-protected
  • Password-protected
curl -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"getBalance","params":["23dQfKhhsZ9RA5AAn12KGk21MB784PmTB3gfKRwdBNHr"],"id":1}' \
  https://nd-123-456-789.p2pify.com/3c6e0b8a9c15224a8228b9a98ca1531d

# Solana web3.js

  1. Install Solana web3.js. See Solana web3.js guide (opens new window).
  2. Use Connection to connect to your Solana node:
const web3 = require("@solana/web3.js");
(async () => {
  const connect = new web3.Connection('ENDPOINT');
  console.log(await connect.getSlot());
})();

where ENDPOINT is your node HTTPS endpoint. See View node access and credentials.

Example to get account balance:

  • Key-protected
  • Password-protected
const web3 = require("@solana/web3.js");
(async () => {
  const publicKey = new web3.PublicKey(
    '23dQfKhhsZ9RA5AAn12KGk21MB784PmTB3gfKRwdBNHr'
  );
  const connect = new web3.Connection('https://nd-123-456-789.p2pify.com/3c6e0b8a9c15224a8228b9a98ca1531d');
  console.log(await connect.getBalance(publicKey));
})();

# Solana.py

  1. Install Solana.py (opens new window).
  2. Use Client to connect to your Solana node:
from solana.rpc.api import Client
client = Client('ENDPOINT')
print(client.get_slot())

where ENDPOINT is your node HTTPS endpoint.

Example to get account balance:

  • Key-protected
  • Password-protected
from solana.rpc.api import Client
from solana.publickey import PublicKey
client = Client('https://nd-123-456-789.p2pify.com/3c6e0b8a9c15224a8228b9a98ca1531')
print(client.get_balance(PublicKey('23dQfKhhsZ9RA5AAn12KGk21MB784PmTB3gfKRwdBNHr')))