JSON-RPC APIs

Introduction

Taker Chain provides Ethereum compatibility through its JSON-RPC interface, enabling developers to interact with the chain using familiar Ethereum tooling and methods. This document outlines the supported Ethereum JSON-RPC methods and provides examples to help you integrate them into your workflows.

For testing, use the Taker Chain TestNet endpoint:

https://rpc-testnet.taker.xyz/

Available Methods

Below is a list of supported JSON-RPC methods with their descriptions, parameters, and examples:


eth_accounts

Returns a list of addresses owned by the client.

Parameters: None

Example:

curl -X POST https://rpc-testnet.taker.xyz/ \
-H "Content-Type: application/json" \
--data '{
    "jsonrpc":"2.0",
    "method":"eth_accounts",
    "params":[],
    "id":1
}'

eth_blockNumber

Returns the number of the most recent block.

Parameters: None

Example:

curl -X POST https://rpc-testnet.taker.xyz/ \
-H "Content-Type: application/json" \
--data '{
    "jsonrpc":"2.0",
    "method":"eth_blockNumber",
    "params":[],
    "id":1
}'

eth_call

Executes a new message call immediately without creating a transaction.

Parameters:

  • transaction object: The transaction call object:

    • to (string): Recipient address of the call (20-byte data string).

    • data (string): Hash of the method signature and encoded parameters (data string).

    • Other optional fields like from, gas, gasPrice, value, and blockValue.

Example:

curl -X POST https://rpc-testnet.taker.xyz/ \
-H "Content-Type: application/json" \
--data '{
    "jsonrpc":"2.0",
    "method":"eth_call",
    "params":[{
        "to": "INSERT_RECIPIENT_ADDRESS",
        "data": "INSERT_ENCODED_CALL"
    }, "INSERT_BLOCK_VALUE"],
    "id":1
}'

Replace INSERT_RECIPIENT_ADDRESS, INSERT_ENCODED_CALL, and INSERT_BLOCK_VALUE with appropriate values.


eth_chainId

Returns the chain ID used for signing transactions.

Parameters: None

Example:

curl -X POST https://rpc-testnet.taker.xyz/ \
-H "Content-Type: application/json" \
--data '{
    "jsonrpc":"2.0",
    "method":"eth_chainId",
    "params":[],
    "id":1
}'

eth_estimateGas

Estimates the gas required for a transaction.

Parameters:

  • transaction object: The transaction call object:

    • to (string): Recipient address of the call (20-byte data string).

    • data (string): Hash of the method signature and encoded parameters (data string).

    • Other optional fields like from, gas, gasPrice, value, and blockValue.

Example:

curl -X POST https://rpc-testnet.taker.xyz/ \
-H "Content-Type: application/json" \
--data '{
    "jsonrpc":"2.0",
    "method":"eth_estimateGas",
    "params":[{
        "to": "INSERT_RECIPIENT_ADDRESS",
        "data": "INSERT_ENCODED_FUNCTION_CALL"
    }],
    "id":1
}'

Replace INSERT_RECIPIENT_ADDRESS and INSERT_ENCODED_FUNCTION_CALL with appropriate values.


eth_gasPrice

Returns the current gas price in Wei.

Parameters: None

Example:

curl -X POST https://rpc-testnet.taker.xyz/ \
-H "Content-Type: application/json" \
--data '{
    "jsonrpc":"2.0",
    "method":"eth_gasPrice",
    "params":[],
    "id":1
}'

eth_getBalance

Returns the balance of a given address.

Parameters:

  • address (string): Address to query balance (20-byte data string).

  • blockValue (string): (Optional) Block tag or block number to fetch.

Example:

curl -X POST https://rpc-testnet.taker.xyz/ \
-H "Content-Type: application/json" \
--data '{
    "jsonrpc":"2.0",
    "method":"eth_getBalance",
    "params":["INSERT_ADDRESS", "INSERT_BLOCK_VALUE"],
    "id":1
}'

Replace INSERT_ADDRESS and INSERT_BLOCK_VALUE with appropriate values.


eth_getBlockByHash

Returns information about a block by its hash.

Parameters:

  • blockHash (string): Hash of the block (32-byte data string).

  • fullTransactions (boolean): If true, returns full transaction details; otherwise, only transaction hashes.

Example:

curl -X POST https://rpc-testnet.taker.xyz/ \
-H "Content-Type: application/json" \
--data '{
    "jsonrpc":"2.0",
    "method":"eth_getBlockByHash",
    "params":["INSERT_BLOCK_HASH", INSERT_BOOLEAN],
    "id":1
}'

Replace INSERT_BLOCK_HASH and INSERT_BOOLEAN with appropriate values.


eth_getBlockByNumber

Returns information about a block by its number.

Parameters:

  • blockValue (string): Block tag or block number.

  • fullTransactions (boolean): If true, returns full transaction details; otherwise, only transaction hashes.

Example:

curl -X POST https://rpc-testnet.taker.xyz/ \
-H "Content-Type: application/json" \
--data '{
    "jsonrpc":"2.0",
    "method":"eth_getBlockByNumber",
    "params":["INSERT_BLOCK_VALUE", INSERT_BOOLEAN],
    "id":1
}'

Replace INSERT_BLOCK_VALUE and INSERT_BOOLEAN with appropriate values.


Response Format

All responses follow the standard JSON-RPC 2.0 format:

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": ... // The return value varies by method
}

Error Handling

If an error occurs, the response will include an error object:

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

Additional Methods

Refer to the full list above for additional methods like eth_getTransactionByHash, eth_sendTransaction, eth_syncing, and more. Each method includes detailed parameters and examples to help you integrate with Taker Chain's JSON-RPC interface.


Start building with Taker Chain's Ethereum-compatible JSON-RPC API today!

Last updated