Formatting conventions and references for use with ZKsync Era API docs.

Hex value encoding

Two key data types get passed over JSON: unformatted byte arrays and quantities. Both are passed with a hex encoding but with different requirements for formatting.


When encoding quantities (integers, numbers): encode as hex, prefix with "0x", the most compact representation (slight exception: zero should be represented as "0x0").

Here are some examples:

  • 0x41 (65 in decimal)
  • 0x400 (1024 in decimal)
  • WRONG: 0x (should always have at least one digit - zero is "0x0")
  • WRONG: 0x0400 (no leading zeroes allowed)
  • WRONG: ff (must be prefixed 0x)

Unformatted data

When encoding unformatted data (byte arrays, account addresses, hashes, bytecode arrays): encode as hex, prefix with "0x", two hex digits per byte.

Here are some examples:

  • 0x41 (size 1, "A")
  • 0x004200 (size 3, "\0B\0")
  • 0x (size 0, "")
  • WRONG: 0xf0f0f (must be even number of digits)
  • WRONG: 004200 (must be prefixed 0x)

Error Codes

CategoryError CodeMessageDescription
Standard-32700Parse errorThe JSON payload could not be parsed due to invalid syntax.
Standard-32600Invalid requestThe JSON object is not a valid request structure.
Standard-32601Method not foundThe requested method does not exist or is not available.
Standard-32602Invalid paramsThe parameters provided to the method are invalid or malformed.
Standard-32603Internal errorAn unspecified internal error occurred within the JSON-RPC framework.

The default block parameter

When requests are made that act on the state of Ethereum, the last default block parameter determines the height of the block.

The following options are possible for the defaultBlock parameter:

  • HEX String - an integer block number
  • String "earliest" for the earliest/genesis block
  • String "latest" - for the latest mined block
  • String "safe" - for the latest safe head block
  • String "finalized" - for the latest finalized block
  • String "pending" - for the pending state/transactions

Made with ❤️ by the ZKsync Community