Skip to content
LogoLogo

createAccessList

Creates an EIP-2930 access list based on a transaction request.

Usage

import { ,  } from './config'
 
const  = await .createAccessList({ 
  : '0xdeadbeef',
  : '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 {  } from 'viem'
 
const  = await .createAccessList({
  : '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', 
  : '0xdeadbeef',
  : '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'
})

blockNumber (optional)

  • Type: number

Block number to create an access list for.

import {  } from 'viem'
 
const  = await .createAccessList({
  : 15121123n, 
  : '0xdeadbeef',
  : '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'
})

blockTag (optional)

  • Type: 'latest' | 'earliest' | 'pending' | 'safe' | 'finalized'
  • Default: 'latest'

Block tag to create an access list for.

import {  } from 'viem'
 
const  = await .createAccessList({
  : 'safe', 
  : '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  : '0xdeadbeef',
  : '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
})

data (optional)

  • Type: 0x${string}

Contract function selector with encoded arguments.

import {  } from 'viem'
 
const  = await .createAccessList({
  : '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  : '0xdeadbeef', 
  : '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'
})

gasPrice (optional)

  • Type: bigint

The price (in wei) to pay per gas. Only applies to Legacy Transactions.

import { ,  } from 'viem'
 
const  = await .createAccessList({
  : '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  : '0xdeadbeef',
  : ('20'), 
  : '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'
})

maxFeePerGas (optional)

  • Type: bigint

Total fee per gas (in wei), inclusive of maxPriorityFeePerGas. Only applies to EIP-1559 Transactions

import { ,  } from 'viem'
 
const  = await .createAccessList({
  : '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  : '0xdeadbeef',
  : ('20'),  
  : '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'
})

maxPriorityFeePerGas (optional)

  • Type: bigint

Max priority fee per gas (in wei). Only applies to EIP-1559 Transactions

import { ,  } from 'viem'
 
const  = await .createAccessList({
  : '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  : '0xdeadbeef',
  : ('20'),
  : ('2'), 
  : '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'
})

to (optional)

Transaction recipient.

import {  } from 'viem'
 
const  = await .createAccessList({
  : '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  : '0xdeadbeef',
  : '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', 
})

value (optional)

  • Type: bigint

Value (in wei) sent with this transaction.

import {  } from 'viem'
 
const  = await .createAccessList({
  : '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  : '0xdeadbeef',
  : '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  : ('1') 
})