# eth_createAccessList

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://linea-mainnet.g.alchemy.com/v2/{apiKey}

Generates an access list for a transaction.

Reference: https://www.alchemy.com/docs/chains/linea/linea-api-endpoints/eth-create-access-list

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| Transaction | object | Yes | The transaction object for which to generate an access list. |
| Block | string or enum | No | The block number or tag at which to create the access list. Defaults to `'latest'` if not provided. |

## Result

**Access list result** (object): An object containing the access list and gas used for the transaction.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "eth_createAccessList",
  "params": [
    {
      "from": "0xaea8f8f781326bfe6a7683c2bd48dd6aa4d3ba63",
      "data": "0x608060806080608155"
    },
    "latest"
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "accessList": [
      {
        "address": "0xa02457e5dfd32bda5fc7e1f1b008aa5979568150",
        "storageKeys": [
          "0x0000000000000000000000000000000000000000000000000000000000000081"
        ]
      }
    ],
    "gasUsed": "0x125f8"
  },
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://linea-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_createAccessList",
  "params": [
    {
      "type": "string",
      "nonce": "string",
      "to": null,
      "from": "string",
      "gas": "string",
      "value": "string",
      "input": "string",
      "gasPrice": "string",
      "maxPriorityFeePerGas": "string",
      "maxFeePerGas": "string",
      "maxFeePerBlobGas": "string",
      "accessList": [
        {
          "address": "string",
          "storageKeys": [
            "string"
          ]
        }
      ],
      "blobVersionedHashes": [
        "string"
      ],
      "blobs": [
        "string"
      ],
      "chainId": "string"
    },
    "string"
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'eth_createAccessList',
    params: [
      {
        type: 'string',
        nonce: 'string',
        to: null,
        from: 'string',
        gas: 'string',
        value: 'string',
        input: 'string',
        gasPrice: 'string',
        maxPriorityFeePerGas: 'string',
        maxFeePerGas: 'string',
        maxFeePerBlobGas: 'string',
        accessList: [{address: 'string', storageKeys: ['string']}],
        blobVersionedHashes: ['string'],
        blobs: ['string'],
        chainId: 'string'
      },
      'string'
    ]
  })
};

fetch('https://linea-mainnet.g.alchemy.com/v2/docs-demo', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://linea-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_createAccessList",
    "params": [
        {
            "type": "string",
            "nonce": "string",
            "to": None,
            "from": "string",
            "gas": "string",
            "value": "string",
            "input": "string",
            "gasPrice": "string",
            "maxPriorityFeePerGas": "string",
            "maxFeePerGas": "string",
            "maxFeePerBlobGas": "string",
            "accessList": [
                {
                    "address": "string",
                    "storageKeys": ["string"]
                }
            ],
            "blobVersionedHashes": ["string"],
            "blobs": ["string"],
            "chainId": "string"
        },
        "string"
    ]
}
headers = {"Content-Type": "application/json"}

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

print(response.text)
```

### Go

```go
package main

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

func main() {

	url := "https://linea-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_createAccessList\",\n  \"params\": [\n    {\n      \"type\": \"string\",\n      \"nonce\": \"string\",\n      \"to\": null,\n      \"from\": \"string\",\n      \"gas\": \"string\",\n      \"value\": \"string\",\n      \"input\": \"string\",\n      \"gasPrice\": \"string\",\n      \"maxPriorityFeePerGas\": \"string\",\n      \"maxFeePerGas\": \"string\",\n      \"maxFeePerBlobGas\": \"string\",\n      \"accessList\": [\n        {\n          \"address\": \"string\",\n          \"storageKeys\": [\n            \"string\"\n          ]\n        }\n      ],\n      \"blobVersionedHashes\": [\n        \"string\"\n      ],\n      \"blobs\": [\n        \"string\"\n      ],\n      \"chainId\": \"string\"\n    },\n    \"string\"\n  ]\n}")

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

	req.Header.Add("Content-Type", "application/json")

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

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

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://linea-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_createAccessList\",\n  \"params\": [\n    {\n      \"type\": \"string\",\n      \"nonce\": \"string\",\n      \"to\": null,\n      \"from\": \"string\",\n      \"gas\": \"string\",\n      \"value\": \"string\",\n      \"input\": \"string\",\n      \"gasPrice\": \"string\",\n      \"maxPriorityFeePerGas\": \"string\",\n      \"maxFeePerGas\": \"string\",\n      \"maxFeePerBlobGas\": \"string\",\n      \"accessList\": [\n        {\n          \"address\": \"string\",\n          \"storageKeys\": [\n            \"string\"\n          ]\n        }\n      ],\n      \"blobVersionedHashes\": [\n        \"string\"\n      ],\n      \"blobs\": [\n        \"string\"\n      ],\n      \"chainId\": \"string\"\n    },\n    \"string\"\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://linea-mainnet.g.alchemy.com/v2/docs-demo");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_createAccessList\",\n  \"params\": [\n    {\n      \"type\": \"string\",\n      \"nonce\": \"string\",\n      \"to\": null,\n      \"from\": \"string\",\n      \"gas\": \"string\",\n      \"value\": \"string\",\n      \"input\": \"string\",\n      \"gasPrice\": \"string\",\n      \"maxPriorityFeePerGas\": \"string\",\n      \"maxFeePerGas\": \"string\",\n      \"maxFeePerBlobGas\": \"string\",\n      \"accessList\": [\n        {\n          \"address\": \"string\",\n          \"storageKeys\": [\n            \"string\"\n          ]\n        }\n      ],\n      \"blobVersionedHashes\": [\n        \"string\"\n      ],\n      \"blobs\": [\n        \"string\"\n      ],\n      \"chainId\": \"string\"\n    },\n    \"string\"\n  ]\n}", false);
var response = await client.PostAsync(request);

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

```


## OpenRPC Method Specification

```yaml
name: eth_createAccessList
description: Generates an access list for a transaction.
params:
  - name: Transaction
    required: true
    description: The transaction object for which to generate an access list.
    schema:
      type: object
      title: Transaction object generic to all types
      description: Parameters describing a transaction/message call.
      additionalProperties: false
      properties:
        type:
          title: type
          description: Transaction type byte (per EIP-2718), e.g., 0x0 (legacy), 0x1 (EIP-2930), 0x2 (EIP-1559), 0x3 (EIP-4844).
          type: string
          pattern: ^0x([0-9a-fA-F]?){1,2}$
        nonce:
          title: nonce
          description: Number of prior transactions sent from the sender account.
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        to:
          title: to address
          description: Recipient of the call. Use null to indicate contract creation.
          oneOf:
            - title: Contract Creation (null)
              description: Null to create a contract; the address is derived from sender and nonce.
              type: 'null'
            - title: Address
              type: string
              pattern: ^0x[0-9a-fA-F]{40}$
              description: 20-byte address of the recipient account or contract.
        from:
          title: from address
          type: string
          pattern: ^0x[0-9a-fA-F]{40}$
          description: 20-byte address of the sender (msg.sender).
        gas:
          title: gas limit
          description: Maximum gas provided for execution.
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        value:
          title: value
          description: Amount of Ether to transfer with the call, in wei.
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        input:
          title: input data
          type: string
          pattern: ^0x[0-9a-f]*$
          description: Calldata for the call (hex-encoded bytes).
        gasPrice:
          title: gas price
          description: The gas price willing to be paid by the sender in wei
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        maxPriorityFeePerGas:
          title: max priority fee per gas
          description: Maximum fee per gas the sender is willing to pay to miners in wei
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        maxFeePerGas:
          title: max fee per gas
          description: The maximum total fee per gas the sender is willing to pay (includes the network / base fee and miner / priority fee) in wei
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        maxFeePerBlobGas:
          title: max fee per blob gas
          description: The maximum total fee per gas the sender is willing to pay for blob gas in wei
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        accessList:
          title: accessList
          description: EIP-2930 access list of pre-touched addresses and storage keys.
          type: array
          items:
            title: Access list entry
            type: object
            additionalProperties: false
            properties:
              address:
                title: hex encoded address
                type: string
                pattern: ^0x[0-9a-fA-F]{40}$
              storageKeys:
                type: array
                items:
                  title: 32 byte hex value
                  type: string
                  pattern: ^0x[0-9a-f]{64}$
        blobVersionedHashes:
          title: blobVersionedHashes
          description: List of versioned blob hashes associated with the transaction's EIP-4844 data blobs.
          type: array
          items:
            title: 32 byte hex value
            type: string
            pattern: ^0x[0-9a-f]{64}$
        blobs:
          title: blobs
          description: Raw EIP-4844 blob data (each item is a binary-encoded blob).
          type: array
          items:
            title: hex encoded bytes
            type: string
            pattern: ^0x[0-9a-f]*$
        chainId:
          title: chainId
          description: Chain ID that this transaction is valid on.
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
  - name: Block
    required: false
    description: The block number or tag at which to create the access list. Defaults to `'latest'` if not provided.
    schema:
      title: Block number or tag
      oneOf:
        - title: Block number
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        - title: Block tag
          type: string
          enum:
            - earliest
            - finalized
            - safe
            - latest
            - pending
          description: '`earliest`: The lowest numbered block the client has available; `finalized`: The most recent crypto-economically secure block, cannot be re-orged outside of manual intervention driven by community coordination; `safe`: The most recent block that is safe from re-orgs under honest majority and certain synchronicity assumptions; `latest`: The most recent block in the canonical chain observed by the client, this block may be re-orged out of the canonical chain even under healthy/normal conditions; `pending`: A sample next block built by the client on top of `latest` and containing the set of transactions usually taken from local mempool. Before the merge transition is finalized, any call querying for `finalized` or `safe` block MUST be responded to with `-39001: Unknown block` error'
result:
  name: Access list result
  description: An object containing the access list and gas used for the transaction.
  schema:
    title: Access list result
    type: object
    additionalProperties: false
    properties:
      accessList:
        title: Access list
        description: The generated access list for the transaction.
        type: array
        items:
          title: Access list entry
          type: object
          additionalProperties: false
          properties:
            address:
              title: hex encoded address
              type: string
              pattern: ^0x[0-9a-fA-F]{40}$
            storageKeys:
              type: array
              items:
                title: 32 byte hex value
                type: string
                pattern: ^0x[0-9a-f]{64}$
      error:
        title: Error
        description: Any error encountered during access list generation.
        type: string
      gasUsed:
        title: Gas used
        description: The estimated gas used for the transaction with the access list, as a hexadecimal string.
        type: string
        pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
examples:
  - name: eth_createAccessList example
    params:
      - name: Transaction
        value:
          from: '0xaea8f8f781326bfe6a7683c2bd48dd6aa4d3ba63'
          data: '0x608060806080608155'
      - name: Block
        value: latest
    result:
      name: Access list result
      value:
        accessList:
          - address: '0xa02457e5dfd32bda5fc7e1f1b008aa5979568150'
            storageKeys:
              - '0x0000000000000000000000000000000000000000000000000000000000000081'
        gasUsed: '0x125f8'
```
