NEXUS

JSON-RPC

CROSS Chain: Interacting with the Blockchain via JSON-RPC

To interact with CROSS Chain, you need to utilize JSON-RPC to handle transactions with the network. This protocol allows you to send transactions to the CROSS Chain network, retrieve data, and more.


1. What is JSON-RPC?

JSON-RPC is a remote procedure call (RPC) protocol that provides a simple and lightweight way to interact with blockchain networks. The protocol is stateless and can operate across different environments using JSON (RFC 4627) for data formatting. It is flexible and can work over various transport layers like HTTP and sockets.

CROSS Chain implements JSON-RPC to provide developers with access to blockchain data, transaction processing, and other features.


2. CROSS Chain JSON-RPC API Specification

CROSS Chain is fully compatible with the Ethereum JSON-RPC specification. This means any Ethereum-compatible tool can also work with CROSS Chain.

Network Endpoints

Mainnet

Testnet


3. JSON-RPC Request Structure

Request Format

{
  "jsonrpc": "2.0",
  "method": "method_name",
  "params": [param1, param2],
  "id": 1
}

Response Format

Success:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": { ... }
}

Error:

{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32000,
    "message": "Error message",
    "data": "Details"
  }
}

4. Example JSON-RPC Method Calls

4.1 Get Block by Number

{
  "jsonrpc": "2.0",
  "method": "eth_getBlockByNumber",
  "params": ["latest", true],
  "id": 1
}

4.2 Get Transaction by Hash

{
  "jsonrpc": "2.0",
  "method": "eth_getTransactionByHash",
  "params": ["0xd7b510d535e8f107..."],
  "id": 1
}

4.3 Get Account Balance

{
  "jsonrpc": "2.0",
  "method": "eth_getBalance",
  "params": ["0xe5dFec1e7Ca7AA90...", "latest"],
  "id": 1
}

4.4 Send Transaction

{
  "jsonrpc": "2.0",
  "method": "eth_sendTransaction",
  "params": [{
    "from": "0x...",
    "to": "0x...",
    "gas": "0x76c0",
    "gasPrice": "0x9184e72a000",
    "value": "0xde0b6b3a7640000",
    "data": "0x"
  }],
  "id": 1
}

4.5 Smart Contract Call

{
  "jsonrpc": "2.0",
  "method": "eth_call",
  "params": [
    {
      "to": "0x6b175474e89094c44da98b954eedeac495271d0f",
      "data": "0x70a0823100000000..."
    },
    "latest"
  ],
  "id": 1
}

5. Interacting with CROSS Chain using curl

Get Latest Block Number (Mainnet)

curl -X POST https://mainnet.cross-nexus.com \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'

Get Account Balance (Testnet)

curl -X POST https://testnet.cross-nexus.com \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x...", "latest"],"id":1}'

6. Commonly Used JSON-RPC Methods

MethodDescription
eth_blockNumberReturns the number of the most recent block
eth_getBalanceReturns balance of the account at given address
eth_getBlockByNumberReturns information about a block by number
eth_getBlockByHashReturns block info using block hash
eth_getTransactionCountReturns the number of transactions from address
eth_getTransactionByHashReturns transaction details by hash
eth_getTransactionReceiptReturns transaction receipt
eth_sendRawTransactionSubmits a raw, signed transaction
eth_callCalls a smart contract function without state changes
eth_estimateGasEstimates gas required for a transaction
eth_getLogsReturns logs based on filter object
net_versionReturns current network ID

7. JSON-RPC Error Codes

CodeMessageDescription
-32700Parse errorInvalid JSON
-32600Invalid RequestThe JSON sent is not a valid request
-32601Method not foundMethod does not exist
-32602Invalid paramsInvalid method parameters
-32603Internal errorInternal JSON-RPC error
-32000 to -32099Server errorGeneric server-side errors

8. Security Considerations

  1. Always use HTTPS when communicating over public networks
  2. Limit API access when exposing nodes to the internet
  3. Perform sensitive operations like private key handling offline
  4. Validate data before sending transactions
  5. Set appropriate gas limits for contract interaction

© 2025 NEXUS Co., Ltd. All Rights Reserved.