1. CRX
  2. API reference
  3. Funds
  4. Send a chain call

Send a chain call

POST/rpc

The account's chain call route. It takes the Ethereum JSON-RPC calls a deposit needs, so the account needs no chain connection of its own. The CRX Python SDK sends its chain calls here by default on ethereum.

Send one JSON-RPC 2.0 object, params by position, at most 16 KiB. A batch is refused. Sign the call with the signed headers: Path: /rpc, and Body hashes the JSON-RPC body. A session token is refused.

MethodParams
eth_chainId[]
eth_getCode[core, "latest"]
eth_call[call, "latest"]
eth_estimateGas[call]
eth_getTransactionCount[account wallet or delegate, "latest" or "pending"]
eth_getBlockByNumber["latest", false]
eth_gasPrice, eth_maxPriorityFeePerGas[]
eth_sendRawTransaction[signed transaction]
eth_getTransactionReceipt, eth_getTransactionByHash[transaction hash]

core and base_token are the chain's members on GET /health. A call is an object with to and no keys other than from, to and data. to is core or base_token; from is absent, the account wallet or the delegate; data is absent or at most 1024 bytes of hex. Addresses match in any letter case. A transaction hash is 32 bytes of hex.

A signed transaction is type 2 (EIP-1559) for the chain's chain_id, with value 0 and an empty access list, signed by the account wallet or the delegate. It is one of these:

  • approve(address,uint256) to base_token, with core as the spender.
  • deposit(uint256) to core.
  • depositFor(address,uint256) to core, for the account wallet.

Answers. eth_chainId answers with no chain read. The answers of eth_getBlockByNumber, eth_gasPrice and eth_maxPriorityFeePerGas can be up to 12 seconds old. A chain error whose message starts with one of these answers 200 with its code, message and hex data: execution reverted, nonce too low, replacement transaction underpriced, insufficient funds, already known, max fee per gas less than block base fee. Any other chain error answers 503 -32603.

Limits. Per account: 60 calls a minute (burst 30) and 1500 calls a UTC day. eth_sendRawTransaction also counts against 4 sends a minute (burst 4) and 30 sends a UTC day. Over a limit: 429 -32005 with Retry-After. When chain calls are busy for all accounts: 503 -32005 with Retry-After; a send answers 429.

Refusals. The route's own refusals answer a JSON-RPC error with the HTTP status below. The signed-header and access refusals answer the Error body, as on every call. A send that the route refuses before it reaches the chain never answers a JSON-RPC 5xx: it answers 429 over a limit, else 409. An Error body 503 to a send means the send was not sent. A JSON-RPC 503 or a 408 to a send means the send may have reached the chain. Read eth_getTransactionByHash before you send it again.

Authentication

  • x-crx-address x-crx-ts x-crx-sig
  • x-crx-address x-crx-signer x-crx-ts x-crx-sig

Request body

FieldTypeDescription
jsonrpc requiredstring 2.0
idstring or number or null

Returned in the answer.

method requiredstring eth_chainId eth_getCode eth_call eth_estimateGas eth_getTransactionCount eth_getBlockByNumber eth_gasPrice eth_maxPriorityFeePerGas eth_sendRawTransaction eth_getTransactionReceipt eth_getTransactionByHash
paramsarray

Params by position, in the method's shape. Absent or null reads as [].

Responses

200

The method's result, or a passed chain error.

FieldTypeDescription
jsonrpc requiredstring 2.0
id requiredstring or number or null

The request's id; null when the body does not read.

result

The method's answer, as Ethereum JSON-RPC defines it. Absent when error is present.

errorobject
error.code requiredinteger

JSON-RPC error code.

error.message requiredstring

Text to show the user, or the chain's error message.

error.data

A passed chain error: its hex data. A per-minute 429: retry_after_secs.

400

-32700: the body is not JSON. -32600: a batch, not an object, jsonrpc not "2.0", an id that is not a string, a number or null, no method, or params not a list. -32602: params that do not read.

error.code -32700 -32600 -32602

401

unauthorized: a signed header is missing, malformed or out of range, the call was already used, the signature does not match, or the call carries a session token.

code unauthorized

403

-32601: a method off the table. -32602: params that break the method's rule. not_whitelisted: the account is not approved for this call. setup_pending: the account is approved and its setup is in progress. forbidden, account_paused: the account cannot deposit.

error.code -32601 -32602

code not_whitelisted setup_pending forbidden account_paused

408

timeout: no answer within 30 seconds.

code timeout

409

-32603: a send refused before it reached the chain. The chain read failed, or chain calls are not available now.

error.code -32603

413

-32600: the body is over 16 KiB. payload_too_large: the body is over 4 MiB.

error.code -32600

code payload_too_large

429

-32005: over a limit of the account, or a send while chain calls are busy for all accounts. Retry after Retry-After seconds.

error.code -32005

HeaderTypeDescription
Retry-Afterinteger

Seconds until the next call is accepted.

502

upstream: a chain read failed. Retry shortly.

code upstream

503

-32005: chain calls are busy for all accounts; retry after Retry-After. -32603: the chain read failed, or chain calls are not available now. service_unavailable: access cannot be checked now. mark_unavailable: start-up checks are on hold. service_restarting: the service is restarting. Retry shortly.

error.code -32005 -32603

code service_unavailable mark_unavailable service_restarting

HeaderTypeDescription
Retry-Afterinteger

Seconds until the next call is accepted.