createAccessList
Creates an EIP-2930 access list based on a transaction request.
Usage
example.ts
import { account, publicClient } from './config'
 
const result = await publicClient.createAccessList({ 
  data: '0xdeadbeef',
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'
})Returns
{ accessList: AccessList, gasUsed: bigint }
The access list and gas used.
Parameters
account (optional)
- Type: Account | Address
The Account to create an access list for.
import { parseEther } from 'viem'
 
const result = await publicClient.createAccessList({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', 
  data: '0xdeadbeef',
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'
})blockNumber (optional)
- Type: number
Block number to create an access list for.
import { parseEther } from 'viem'
 
const result = await publicClient.createAccessList({
  blockNumber: 15121123n, 
  data: '0xdeadbeef',
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'
})blockTag (optional)
- Type: 'latest' | 'earliest' | 'pending' | 'safe' | 'finalized'
- Default: 'latest'
Block tag to create an access list for.
import { parseEther } from 'viem'
 
const result = await publicClient.createAccessList({
  blockTag: 'safe', 
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  data: '0xdeadbeef',
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
})data (optional)
- Type: 0x${string}
Contract function selector with encoded arguments.
import { parseEther } from 'viem'
 
const result = await publicClient.createAccessList({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  data: '0xdeadbeef', 
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'
})gasPrice (optional)
- Type: bigint
The price (in wei) to pay per gas. Only applies to Legacy Transactions.
import { parseEther, parseGwei } from 'viem'
 
const result = await publicClient.createAccessList({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  data: '0xdeadbeef',
  gasPrice: parseGwei('20'), 
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'
})maxFeePerGas (optional)
- Type: bigint
Total fee per gas (in wei), inclusive of maxPriorityFeePerGas. Only applies to EIP-1559 Transactions
import { parseEther, parseGwei } from 'viem'
 
const result = await publicClient.createAccessList({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  data: '0xdeadbeef',
  maxFeePerGas: parseGwei('20'),  
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'
})maxPriorityFeePerGas (optional)
- Type: bigint
Max priority fee per gas (in wei). Only applies to EIP-1559 Transactions
import { parseEther, parseGwei } from 'viem'
 
const result = await publicClient.createAccessList({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  data: '0xdeadbeef',
  maxFeePerGas: parseGwei('20'),
  maxPriorityFeePerGas: parseGwei('2'), 
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'
})to (optional)
- Type: Address
Transaction recipient.
import { parseEther } from 'viem'
 
const result = await publicClient.createAccessList({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  data: '0xdeadbeef',
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', 
})value (optional)
- Type: bigint
Value (in wei) sent with this transaction.
import { parseEther } from 'viem'
 
const result = await publicClient.createAccessList({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  data: '0xdeadbeef',
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  value: parseEther('1') 
})
