eth_createAccessList

Ethereum API - Creates an EIP2930 type accessList based on a given Transaction object. Returns list of addresses and storage keys that are read and written by the transaction (except the sender account and precompiles), plus the estimated gas consumed when the access list is added.

Parameters

  • TRANSACTION CALL OBJECT [required]

    • from: [optional] 20 Bytes - The address of the sender.

    • to: 20 Bytes - The address the transaction is directed to.

    • gas: [optional] Hexadecimal value of the gas provided for the transaction execution.

    • gasPrice: [optional] Hexadecimal value gas price, in Wei, provided by the sender. The default is 0. Used only in non-EIP1559 transactions.

    • maxPriorityFeePerGas: [optional] Maximum fee, in Wei, the sender is willing to pay per gas above the base fee. See EIP-1559 transactions. If used, must specify maxFeePerGas.

    • maxFeePerGas: [optional] Maximum total fee (base fee + priority fee), in Wei, the sender is willing to pay per gas. See EIP-1559 transactions. If used, must specify maxPriorityFeePerGas.

    • value: [optional] hexadecimal value transferred, in Wei.

    • data: [optional] Hash of the method signature and encoded parameters. See the Ethereum contract ABI specification.

  • BLOCK NUMBER or BLOCK HASH: [required] string representing a block number, block hash, or one of the string tags latest, earliest, or pending.

Returns

access list object with the following fields:

  • accessList: list of objects with the following fields:

    • address: addresses to be accessed by the transaction

    • storageKeys: storage keys to be accessed by the transaction

  • gasUsed: string - approximate gas cost for the transaction if the access list is included

Example

NOTE: In this example we are using public Ethereum endpoint. Ideally, for your own projects, you should use your own endpoint, which you can generate for free by connecting to your wallet here.

Query

NOTE: ethers used below is a well-known web3 library, check it out here.

import { ethers } from 'ethers';

const provider =
  new ethers
    .providers
    .JsonRpcProvider("https://www.noderpc.xyz/rpc-mainnet/public")

const info = async ()=> {
  const result = await provider.send("eth_createAccessList", [
    {"from": "0xaeA8F8f781326bfE6A7683C2BD48Dd6AA4d3Ba63", "data": "0x608060806080608155"}, "latest"
  ]);
  console.log(result);
}
info();

Result

{
    "accessList": [
        {
            "address": "0x45e5af19ae13aac19215266edfab04f8db6f2c53",
            "storageKeys": [
                "0x0000000000000000000000000000000000000000000000000000000000000081"
            ]
        }
    ],
    "gasUsed": "0x12e92"
}

Last updated