JSON-RPC Errors

The format of an error message that the RPC returns:

{
    "jsonrpc": "2.0",
    "error": {
        "code": -32602,
        "message": "Layer1Address deserialize error: incorrect Layer1Address format"
    },
    "id": 1
}
  • code: error code

  • message: error message in English

Error Types

  • -32602: incorrect number of parameters or unable to serialize parameters correctly

  • 100-200: parameter value is not within the correct range

  • 201-300: Incorrect state, such as insufficient account balance for a transfer

  • 500: RPC server internal error

Error Code

The table below lists most error codes and their meanings. While the error codes and meanings generally remain the same, the error messages may change with version iterations. The range from -32768 to -32000 represents the predefined errors in the JSON RPC 2.0 protocol and are less likely to occur if the API documentation is followed. The range from 100 to 500 represents custom errors defined by the zklink RPC server and should be handled by the caller.

Notable Errors

201

When using some APIs that involve querying account status such as getAccount, getAccountSnapshot, etc., if the account does not exist, it will return this error message, rather than returning a default. This is because the account with 'accountId=0' is a Layer3 fee account, and the default accountId is also 0. If the account does not exist, returning the default value will cause confusion.

207

Transaction fees are related to Layer3 token price, which is stable over a period of time (for example, half an hour). If the price is updated just after get_tx_fee, tx_submit may fail. In this case, the initiator need to re-query the transaction fee and then try to submit the transaction again.\

version: 7df6cd1

Last updated