# Tools

Chainstack runs the Pathfinder (opens new window) StarkNet client.

Pathfinder currently supports querying the StarkNet network for state.

For the full list of available queries, see Pathfinder API (opens new window).

# JSON-RPC API

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

curl -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"METHOD","params":[PARAMS]}' ENDPOINT

where

  • METHOD — a supported JSON-RPC API method.
  • PARAMS — request parameters if any.
  • ENDPOINT — your node HTTPS endpoint.

Example to get the latest block:

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

# StarkNet.js

  1. Install StarkNet.js. See StarkNet.js guide (opens new window).
  2. Use RpcProvider to connect to your StarkNet node:
import { RpcProvider } from 'starknet';

const provider = new RpcProvider({
  nodeUrl: 'ENDPOINT',
})

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

Example to get the latest block:

  • Key-protected
  • Password-protected
import { RpcProvider } from 'starknet';
const provider = new RpcProvider({
  nodeUrl: 'https://nd-123-456-789.p2pify.com/3c6e0b8a9c15224a8228b9a98ca1531d',
})
provider.getBlockNumber().then(console.log);

# StarkNet.py

  1. Install StarkNet.py. See StarkNet.py guide (opens new window).
  2. Use FullNodeClient to connect to your StarkNet node:
from starknet_py.net.full_node_client import FullNodeClient

from starknet_py.net.networks import MAINNET

node_url = "ENDPOINT"
full_node_client = FullNodeClient(node_url=node_url, net=MAINNET)

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

Example to retrieve a transaction by hash:

  • Key-protected
  • Password-protected
from starknet_py.net.full_node_client import FullNodeClient

from starknet_py.net.networks import MAINNET

node_url = "https://nd-123-456-789.p2pify.com/3c6e0b8a9c15224a8228b9a98ca1531d"
full_node_client = FullNodeClient(node_url=node_url, net=MAINNET)

call_result = full_node_client.get_transaction_sync(tx_hash="0x50c1941ab13ccc5d9785ceda1d0d7a47be01865eecb795a62f4e589ddca0258")

print(call_result)