createAccessList
Creates an access list for a transaction
Loading...
Creates an access list for a transaction
Creates an access list for a transaction.
Import the public actions package so you can call this action.
import "github.com/ChefBingbong/viem-go/actions/public"An example showing how to construct a public client and generate an access list for a transaction.
import ( "context" "log" "math/big"
"github.com/ethereum/go-ethereum/common" "github.com/ChefBingbong/viem-go/actions/public" "github.com/ChefBingbong/viem-go/client" "github.com/ChefBingbong/viem-go/client/transport" "github.com/ChefBingbong/viem-go/chain/definitions")
ctx := context.Background()
publicClient, err := client.CreatePublicClient(client.PublicClientConfig{ Chain: definitions.Mainnet, Transport: transport.HTTP("https://eth.llamarpc.com"),})if err != nil { log.Fatal(err)}defer func() { _ = publicClient.Close() }()
accessList, err := public.CreateAccessList(ctx, publicClient, public.CreateAccessListParameters{ To: common.HexToAddress("0x..."), Data: []byte{0x12, 0x34, 0x56},})*CreateAccessListReturnType
An access list object containing:
AccessList types.AccessList - The access listGasUsed *big.Int - The gas usedConfiguration options accepted by this action.
*common.AddressThe transaction recipient.
import ( "github.com/ethereum/go-ethereum/common" "github.com/ChefBingbong/viem-go/actions/public")
to := common.HexToAddress("0x70997970C51812dc3A010C7d01b50e0d17dc79C8")accessList, err := public.CreateAccessList(ctx, publicClient, public.CreateAccessListParameters{ To: &to,})[]byteTransaction data.
import "github.com/ChefBingbong/viem-go/actions/public"
accessList, err := public.CreateAccessList(ctx, publicClient, public.CreateAccessListParameters{ Data: []byte{0xc0, 0x2a, 0xaa, 0x39},})*common.AddressThe account to execute the transaction from.
import ( "github.com/ethereum/go-ethereum/common" "github.com/ChefBingbong/viem-go/actions/public")
account := common.HexToAddress("0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266")accessList, err := public.CreateAccessList(ctx, publicClient, public.CreateAccessListParameters{ Account: &account,})*uint64The block number to create the access list at.
import "github.com/ChefBingbong/viem-go/actions/public"
blockNum := uint64(12345)accessList, err := public.CreateAccessList(ctx, publicClient, public.CreateAccessListParameters{ BlockNumber: &blockNum,})BlockTagThe block tag to create the access list at.
import "github.com/ChefBingbong/viem-go/actions/public"
accessList, err := public.CreateAccessList(ctx, publicClient, public.CreateAccessListParameters{ BlockTag: public.BlockTagSafe,})Underlying JSON-RPC method used by this action.