EthereumMethods

eth_createAccessList

The eth_createAccessList method Creates an EIP-2930 access list that can be included in a transaction. This method is essential for optimizing your smart contract interactions. Access lists are a p...

eth_createAccessList

Overview

The 'eth_createAccessList' method Creates an EIP-2930 access list that can be included in a transaction. This method is essential for optimizing your smart contract interactions. Access lists are a part of Ethereum's EIP-2930, aiming to enhance the network's scalability and reduce gas costs by specifying an explicit list of addresses and storage keys that a transaction intends to access.

shell

curl --request POST \
     --url https://ethereum-mainnet-geth-archive.node.coinapi.io \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'X-CoinAPI-Key: 73034021-THIS-IS-SAMPLE-KEY' \
     --data '
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "eth_createAccessList",
  "params": [
    {
      "to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
      "gas": "0x00",
      "gasPrice": "0x09184e72a000",
      "value": "0x00",
      "data": "0x"
    }
  ]
}
'

csharp

using RestSharp; {

var options = new RestClientOptions("https://ethereum-mainnet-geth-archive.node.coinapi.io");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("accept", "application/json", "X-CoinAPI-Key: 73034021-THIS-IS-SAMPLE-KEY");
request.AddJsonBody("{\"id\":1,\"jsonrpc\":\"2.0\",\"method\":\"eth_createAccessList\"}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content); }

php

<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://ethereum-mainnet-geth-archive.node.coinapi.io",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'id' => 1,
'jsonrpc' => '2.0',
'method' => 'eth_createAccessList',
'params' => [
[
'to' => '0xd46e8dd67c5d32be8058bb8eb970870f07244567',
'gas' => '0x00',
'gasPrice' => '0x09184e72a000',
'value' => '0x00',
'data' => '0x'
]
]
]),
CURLOPT_HTTPHEADER => [
"accept: application/json",
"content-type: application/json",
"X-CoinAPI-Key": "73034021-THIS-IS-SAMPLE-KEY"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>

python

import requests

url = "https://ethereum-mainnet-geth-archive.node.coinapi.io"

payload = {
    "id": 1,
    "jsonrpc": "2.0",
    "method": "eth_createAccessList",
    "params": [
        {
            "to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
            "gas": "0x00",
            "gasPrice": "0x09184e72a000",
            "value": "0x00",
            "data": "0x"
        }
    ]
}
headers = {
    "accept": "application/json",
    "content-type": "application/json",
    "X-CoinAPI-Key" : "73034021-THIS-IS-SAMPLE-KEY"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)

javascript

const options = {
  method: 'POST',
  headers: {accept: 'application/json', 'content-type': 'application/json', 'X-CoinAPI-Key' : '73034021-THIS-IS-SAMPLE-KEY'},
  body: JSON.stringify({
    id: 1,
    jsonrpc: '2.0',
    method: 'eth_createAccessList',
    params: [
      {
        to: '0xd46e8dd67c5d32be8058bb8eb970870f07244567',
        gas: '0x00',
        gasPrice: '0x09184e72a000',
        value: '0x00',
        data: '0x'
      }
    ]
  })
};

fetch('https://ethereum-mainnet-geth-archive.node.coinapi.io', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

go

package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://ethereum-mainnet-geth-archive.node.coinapi.io"

	payload := strings.NewReader("{\"id\":1,\"jsonrpc\":\"2.0\",\"method\":\"eth_createAccessList\",\"params\":[{\"to\":\"0xd46e8dd67c5d32be8058bb8eb970870f07244567\",\"gas\":\"0x00\",\"gasPrice\":\"0x09184e72a000\",\"value\":\"0x00\",\"data\":\"0x\"}]}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("accept", "application/json")
	req.Header.Add("content-type", "application/json")
  req.Header.Add("X-CoinAPI-Key", "73034021-THIS-IS-SAMPLE-KEY")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}

ruby

require 'uri'
require 'net/http'

url = URI("https://ethereum-mainnet-geth-archive.node.coinapi.io")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["accept"] = 'application/json'
request["content-type"] = 'application/json'
request["X-CoinAPI-Key"] = '73034021-THIS-IS-SAMPLE-KEY'
request.body = "{\"id\":1,\"jsonrpc\":\"2.0\",\"method\":\"eth_createAccessList\",\"params\":[{\"to\":\"0xd46e8dd67c5d32be8058bb8eb970870f07244567\",\"gas\":\"0x00\",\"gasPrice\":\"0x09184e72a000\",\"value\":\"0x00\",\"data\":\"0x\"}]}"

response = http.request(request)
puts response.read_body

java

OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"id\":1,\"jsonrpc\":\"2.0\",\"method\":\"eth_createAccessList\",\"params\":[{\"to\":\"0xd46e8dd67c5d32be8058bb8eb970870f07244567\",\"gas\":\"0x00\",\"gasPrice\":\"0x09184e72a000\",\"value\":\"0x00\",\"data\":\"0x\"}]}");
Request request = new Request.Builder()
  .url("https://eth-mainnet.g.alchemy.com/v2/docs-demo")
  .post(body)
  .addHeader("accept", "application/json")
  .addHeader("content-type", "application/json")
  .addHeader("X-CoinAPI-Key", "73034021-THIS-IS-SAMPLE-KEY")
  .build();

Response response = client.newCall(request).execute();

Request Parameters

  1. Transaction call object:
  • 'from' [optional]: 20 bytes. The address of the sender.
  • 'to': 20 bytes. 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-EIP-1559 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 of the value transferred, in Wei.
  • 'data' [optional]: Hash of the method signature and encoded parameters. See Ethereum contract ABI specification.
  1. Block number or block hash [required]: A string representing a block number, block hash, or one of the string tags latest, earliest, or pending. Refer to the default block parameter.

  2. Access list object:

  • 'accessList': A 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': A hexadecimal string representing the approximate gas cost for the transaction if the access list is included.

Response

{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32602,
    "message": "invalid argument 0: json: cannot unmarshal hex number with leading zero digits into Go struct field TransactionArgs.gas of type hexutil.Uint64"
  }
}
Service StatusGitHub SDK