Skip to main content

Don't have an RPC Node yet?

Start using RPC Nodes in your project today.

Get your free RPC Node
Version: 2.2

eth_createAccessList

Create Access List​

POSThttps://site1.moralis-nodes.com/:chain/:apiKey

This example demonstrates generating an access list for a hypothetical transaction that interacts with a contract. The access list helps in optimizing gas costs for transactions by pre-specifying accounts and storage keys the transaction intends to access.

Note

Please refer to RPC schema page for more details on the RPC params and RPC response definitions of the RPC method.

PATH PARAMS
chainstringrequired
The blockchain to interact with. In this example, 'eth' is used to denote Ethereum Mainnet.
apiKeystringrequired
Your API key for authentication. Replace 'YOUR_API_KEY' with your actual Moralis API key.
BODY PARAM
jsonrpcstringrequired
Specifies the JSON-RPC protocol version, which is 2.0 for this example.
idnumberrequired
A unique identifier for the request.
methodstringrequired
The JSON-RPC method being called. For creating an access list, 'eth_createAccessList' is used.
paramsrpcArrayrequired
An array containing the transaction object for which to generate the access list, and optionally the block number.
Responses
// Dependencies to install:
// $ npm install node-fetch --save
// add "type": "module" to package.json

import fetch from 'node-fetch';

const options = {
method: 'POST',
headers: {
accept: 'application/json',
'content-type': 'application/json'
},
body: JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"method": "eth_createAccessList"
})
};

fetch('https://site1.moralis-nodes.com/eth/YOUR_API_KEY', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
Response Example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"accessList": [
""
],
"gasUsed": "0x5208"
}
}