prepareTransactionRequest
Action for preparing a transaction request for signing by populating a nonce, gas limit, fee values, and a transaction type.
Import
import { prepareTransactionRequest } from '@wagmi/core'
import { prepareTransactionRequest } from '@wagmi/core'
Usage
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
Parameters
import { type PrepareTransactionRequestParameters } from '@wagmi/core'
import { type PrepareTransactionRequestParameters } from '@wagmi/core'
account
Account | Address | undefined
The Account to send the transaction from.
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
to
`0x${string}` | undefined
The transaction recipient or contract address.
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
accessList
AccessList | undefined
The access list.
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
accessList: [
{
address: '0x1',
storageKeys: ['0x1'],
},
],
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
accessList: [
{
address: '0x1',
storageKeys: ['0x1'],
},
],
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
chainId
config['chains'][number]['id'] | undefined
Chain ID to prepare the transaction request for.
import { prepareTransactionRequest } from '@wagmi/core'
import { mainnet } from '@wagmi/core/chains'
import { parseEther } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
chainId: mainnet.id,
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { prepareTransactionRequest } from '@wagmi/core'
import { mainnet } from '@wagmi/core/chains'
import { parseEther } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
chainId: mainnet.id,
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
data
`0x${string}` | undefined
A contract hashed method call with encoded args.
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
data: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
data: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
gasPrice
bigint | undefined
The price (in wei) to pay per gas. Only applies to Legacy Transactions.
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther, parseGwei } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
gasPrice: parseGwei('20'),
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther, parseGwei } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
gasPrice: parseGwei('20'),
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
maxFeePerGas
bigint | undefined
Total fee per gas (in wei), inclusive of maxPriorityFeePerGas
. Only applies to EIP-1559 Transactions.
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther, parseGwei } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
maxFeePerGas: parseGwei('20'),
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther, parseGwei } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
maxFeePerGas: parseGwei('20'),
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
maxPriorityFeePerGas
bigint | undefined
Max priority fee per gas (in wei). Only applies to EIP-1559 Transactions.
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther, parseGwei } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
maxFeePerGas: parseGwei('20'),
maxPriorityFeePerGas: parseGwei('2'),
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther, parseGwei } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
maxFeePerGas: parseGwei('20'),
maxPriorityFeePerGas: parseGwei('2'),
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
nonce
number | undefined
Unique number identifying this transaction.
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
nonce: 5,
})
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
nonce: 5,
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
parameters
("fees" | "gas" | "nonce" | "type")[] | undefined
Parameters to prepare.
For instance, if ["gas", "nonce"]
is provided, then only the gas
and nonce
parameters will be prepared.
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
parameters: ['gas', 'nonce'],
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
parameters: ['gas', 'nonce'],
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
value
bigint | undefined
The transaction recipient or contract address.
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { prepareTransactionRequest } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
await prepareTransactionRequest(config, {
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'),
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
Return Type
import { type PrepareTransactionRequestReturnType } from '@wagmi/core'
import { type PrepareTransactionRequestReturnType } from '@wagmi/core'
The transaction request.
Error
import { type PrepareTransactionRequestErrorType } from '@wagmi/core'
import { type PrepareTransactionRequestErrorType } from '@wagmi/core'
TanStack Query
import {
type prepareTransactionRequestData,
type prepareTransactionRequestOptions,
type prepareTransactionRequestQueryFnData,
type prepareTransactionRequestQueryKey,
prepareTransactionRequestQueryKey,
prepareTransactionRequestQueryOptions,
} from '@wagmi/core/query'
import {
type prepareTransactionRequestData,
type prepareTransactionRequestOptions,
type prepareTransactionRequestQueryFnData,
type prepareTransactionRequestQueryKey,
prepareTransactionRequestQueryKey,
prepareTransactionRequestQueryOptions,
} from '@wagmi/core/query'