Querying Blockchain Data

Querying blockchain data on Celestium allows users and developers to retrieve information about blocks, transactions, balances, and contract states. This can be done using Ethereum-compatible JSON-RPC API methods.


Common RPC Methods

Below are the most commonly used RPC methods to query data from Celestium:

Get the Latest Block Number

Returns the current block number.

curl -X POST http://rpc-private-testnet.celestium.network -H "Content-Type: application/json" --data '{
  "jsonrpc":"2.0",
  "method":"eth_blockNumber",
  "params":[],
  "id":1
}'

Get Block Details by Number

Fetches details of a specific block.

curl -X POST http://rpc-private-testnet.celestium.network -H "Content-Type: application/json" --data '{
  "jsonrpc":"2.0",
  "method":"eth_getBlockByNumber",
  "params":["0xBLOCK_NUMBER", true],
  "id":1
}'

Replace BLOCK_NUMBER with a hexadecimal block number (e.g., 0x1A for block 26).

Get Transaction Details

Fetches the details of a transaction by its hash.

curl -X POST http://rpc-private-testnet.celestium.network -H "Content-Type: application/json" --data '{
  "jsonrpc":"2.0",
  "method":"eth_getTransactionByHash",
  "params":["0xTRANSACTION_HASH"],
  "id":1
}'

Replace TRANSACTION_HASH with the transaction hash.

Get Transaction Receipt

Checks the status and logs of a transaction.

curl -X POST http://rpc-private-testnet.celestium.network -H "Content-Type: application/json" --data '{
  "jsonrpc":"2.0",
  "method":"eth_getTransactionReceipt",
  "params":["0xTRANSACTION_HASH"],
  "id":1
}'

Get Account Balance

Retrieves the balance of an account in wei.

curl -X POST http://rpc-private-testnet.celestium.network -H "Content-Type: application/json" --data '{
  "jsonrpc":"2.0",
  "method":"eth_getBalance",
  "params":["0xADDRESS", "latest"],
  "id":1
}'

Replace ADDRESS with the account address.


Interacting with Blockchain Programmatically

You can also use libraries like ethers.js or web3.js to query blockchain data within your application:

const { ethers } = require("ethers");

const provider = new ethers.JsonRpcProvider("http://rpc-private-testnet.celestium.network");

const balance = await provider.getBalance("0xADDRESS");
console.log(`Balance: ${ethers.formatEther(balance)} CLT`);

Using Celestium Explorer

For a user-friendly way to explore transactions, blocks, and addresses, visit the Celestium Testnet Explorer:

🔗 http://testnet.celestium.network


Querying blockchain data is essential for monitoring transactions, tracking balances, and interacting with smart contracts. Celestium’s compatibility with the Ethereum API ensures that developers can integrate with existing tools seamlessly.

Last updated