Build on X Layer

RPC endpoints#

Note
There is a limit of 100 requests per second per IP address on both the mainnet and testnet.

Mainnet (chain-id: 0xC4, 196 in decimals)#

RPC:

Testnet (chain-id: 0x7A0, 1952 in decimals)#

RPC:

Prerequisite readings#

Before you begin using RPC endpoints on X Layer, it’s important to read the relevant articles for guidance:

Starting HTTP JSON-RPC#

To start the HTTP JSON-RPC, curl method is recommended:

# mainnet
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' -H "Content-Type: application/json" https://rpc.xlayer.tech
# testnet
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' -H "Content-Type: application/json" https://testrpc.xlayer.tech/terigon

JSON-RPC methods#

1. Ethereum compatible RPC#

Here you will find the list of all supported JSON RPC endpoints and the differences between them in comparison to the default behavior of an Ethereum node. If a specific endpoint is not in the list below, it means that this specific endpoint is not supported yet. You can find more details in Ethereum’s JSON-RPC doc.

MethodNamespaceNotes
web3_clientVersionWeb3Get the Web3 client version
web3_sha3Web3Returns keccak-256 (not the standardized SHA3-256) of the given data
net_versionNetReturns the current network ID
eth_protocolVersionETHResponse is always 'zero'
eth_syncingETHReturns an object with data about the sync status or false
eth_gasPriceETHReturns the current Gas price in OKB
eth_blockNumberETHReturns the current block height
eth_chainIdETHReturns the chain’s identifier in hex format
eth_getBalanceETHReturns the account balance for a given account address and block number
eth_getStorageAtETHReturns the storage address for a given account address
eth_getTransactionCountETHReturns the total transaction for a given account address and block number
eth_getBlockTransactionCountByNumberETHReturns the total transaction count for a given block number
eth_getBlockTransactionCountByHashETHReturns the total transaction count for a given block hash
eth_getCodeETHReturns the code for a given account address and block number
eth_signETHThe sign method calculates an Ethereum specific signature
eth_sendTransactionETHSends transaction from given account to a given account
eth_sendRawTransactionETHCreates a new message call transaction or a contract creation for signed transactions
eth_callETHExecutes a new message call immediately without creating a transaction on the blockchain
eth_estimateGasETHReturns an estimated value of the Gas required to send the transaction
eth_getBlockByNumberETHReturns information about a block by block number
eth_getBlockByHashETHReturns the block info given the hash found in the command above and a bool
eth_getTransactionByHashETHReturns transaction details from a transaction hash
eth_getTransactionByBlockHashAndIndexETHReturns transaction details given the block hash and the transaction index
eth_getTransactionReceiptETHReturns the receipt of a transaction by transaction hash
eth_newFilterETHCreates a new filter using topics of some kind
eth_newBlockFilterETHCreates a filter in the node, to notify when a new block arrives
eth_uninstallFilterETHRemoves the filter with the given filter ID
eth_getFilterChangesETHPolling method for a filter, which returns an array of logs which occurred since the last poll
eth_getLogsETHReturns an array of all logs matching a given filter object
eth_getFilterLogsETHReturns an array of all logs matching filters with the given ID
eth_getTransactionbyBlockNumberAndIndexETHReturns transaction details by block height and block index
eth_getCompilersETHResponse is always empty
eth_getUncleCountByBlockHashETHResponse is always empty
eth_getUncleCountByBlockNumberETHResponse is always empty
eth_getUncleByBlockHashAndIndexETHResponse is always empty
eth_getUncleByBlockNumberAndIndexETHResponse is always empty
eth_subscribeWebSocketSubscribe using JSON-RPC notifications
eth_unsubscribeWebSocketUnsubscribe from an event using the subscription ID
debug_traceBlockByHashDebugReturns the possible tracing result number by executing all transactions in the block specified by the block hash with a tracer
debug_traceBlockByNumberDebugReturns the tracing result by executing all transactions in the block specified by number with a tracer (trace mode required)
debug_traceTransactionDebugReturns all traces of a given transaction
txpool_contentTxpoolResponse is always empty

Infrastructure providers#

Public RPCs may have rate limits or traffic restrictions. For dedicated free RPC URLs, consider the following providers: