JSON-RPC Methods

This section lists the Ethereum JSON-RPC methods that you can call with HTTP tools.

These methods are also used by some EVM compliant networks such as:

Agreement

Value encoding

Two key data types are passed through JSON: unformatted byte arrays and quantities. Both are passed using hexadecimal encoding, but have different requirements for formatting.

Quantity

When encoding quantities (integers, numbers): Encode as hexadecimal (prefixed with 0x), eg: 0 should be represented as 0x0.

1. The following is a correct example:

  • 0x41 (65 in decimal)

  • 0x400 (1024 in decimal)

2. The following are examples of errors:

  • Error: 0x (0 is0x0)

  • Error: 0x0400 (leading zeros not allowed)

  • Error: ff (must have prefix 0x)

Data

When encoding unformatted data (byte arrays, account addresses, hashes, bytecode arrays):

  • Encoded as hexadecimal.

  • Prefixed with 0x.

  • Two hexadecimal digits per byte.

1. The following is a correct example:

  • 0x (resolves to empty data)

  • 0x00 (parses to a single 0 byte)

  • 0x41 (resolves to 65)

  • 0x004200 (resolves to 16896)

2. The following are examples of errors:

  • Error:0xf0f0f (number of digits must be even)

  • Error:004200 (must have prefix 0x)

Default block number

When making an Ethereum request, the last default block number parameter determines the height of the block.

The following options are available for default block parameters:

  • HEX - Hexadecimal integer character, eg: 0x670a46

  • earliest - Indicates the earliest/genesis block.

  • latest - The latest mined block.

  • pending - Blocks that represent untransacted status/waiting for transactions

Transaction Type

1. 0x0 Transactions interpreted as legacy, also known as regular transactions, follow EIP-2718. Ethereum originally had a form of transaction, each transaction containing [nonce、gasPrice、gasLimit,to,value,data,v,r,s]. These fields are RLP encoded as follows:

RLP([nonce, gasPrice, gasLimit, to, value, data, v, r, s])

2. 0x1 Interpreted as an access list transaction, following EIP-2930, which contains all parameters of 0x0, adding the accessList parameter, which specifies the address and key storage array (access list) that the transaction plans to access.

3. 0x2 is an EIP-1559 transaction, Ethereum forked in London, which solved the problem of network congestion and overpriced transaction fees caused by the historical fee market. If the user uses the gasPrice parameter to send a transaction specifying a gas price bid, the miner will choose the transaction with the highest bid.

EIP-1559 transactions do not specify a gasPrice, but instead use a dynamically changing Gas base fee within the protocol. In each block, the base fee per gas is adjusted to account for network congestion.

EIP-1559 transaction contains accessList parameters and regular transaction parameters except gasPrice, use maxPriorityFeePerGas to specify the maximum fee that the sender is willing to pay for Gas higher than the basic fee (maximum priority fee per Gas), and maxFeePerGas specifies the maximum total fee (base fee + priority fee) that the sender is willing to pay for Gas.

Last updated