sendTransaction
Action for creating, signing, and sending transactions to networks.
Import
import { sendTransaction } from '@wagmi/core'
Usage
import { sendTransaction } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
const result = await sendTransaction(config, {
to: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
value: parseEther('0.01'),
})
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 SendTransactionParameters } from '@wagmi/core'
accessList
AccessList | undefined
The access list.
import { sendTransaction } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
const result = await sendTransaction(config, {
accessList: [{
address: '0x1',
storageKeys: ['0x1'],
}],
to: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
value: parseEther('0.01'),
})
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(),
},
})
account
Address | Account | undefined
Account to use when sending transaction. Throws if account is not found on connector
.
import { sendTransaction } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
const result = await sendTransaction(config, {
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
to: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
value: parseEther('0.01'),
})
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 validate against before sending transaction.
import { sendTransaction } from '@wagmi/core'
import { mainnet } from '@wagmi/core/chains'
import { parseEther } from 'viem'
import { config } from './config'
const result = await sendTransaction(config, {
chainId: mainnet.id,
to: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
value: parseEther('0.01'),
})
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(),
},
})
connector
Connector | undefined
- Connector to send transaction with.
- Defaults to current connector.
import { getConnections, sendTransaction } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
const connections = getConnections(config)
const result = await sendTransaction(config, {
connector: connections[0]?.connector,
to: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
value: parseEther('0.01'),
})
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 { sendTransaction } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
const result = await sendTransaction(config, {
data: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
to: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
value: parseEther('0.01'),
})
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(),
},
})
gas
bigint | undefined | null
Gas provided for transaction execution.
import { sendTransaction } from '@wagmi/core'
import { parseEther, parseGwei } from 'viem'
import { config } from './config'
const result = await sendTransaction(config, {
gas: parseGwei('20'),
to: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
value: parseEther('0.01'),
})
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 { sendTransaction } from '@wagmi/core'
import { parseEther, parseGwei } from 'viem'
import { config } from './config'
const result = await sendTransaction(config, {
gasPrice: parseGwei('20'),
to: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
value: parseEther('0.01'),
})
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 { sendTransaction } from '@wagmi/core'
import { parseEther, parseGwei } from 'viem'
import { config } from './config'
const result = await sendTransaction(config, {
maxFeePerGas: parseGwei('20'),
to: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
value: parseEther('0.01'),
})
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 { sendTransaction } from '@wagmi/core'
import { parseEther, parseGwei } from 'viem'
import { config } from './config'
const result = await sendTransaction(config, {
maxFeePerGas: parseGwei('20'),
maxPriorityFeePerGas: parseGwei('2'),
to: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
value: parseEther('0.01'),
})
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
Unique number identifying this transaction.
import { sendTransaction } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
const result = await sendTransaction(config, {
nonce: 123,
to: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
value: parseEther('0.01'),
})
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
Address
The transaction recipient or contract address.
import { sendTransaction } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
const result = await sendTransaction(config, {
to: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
value: parseEther('0.01'),
})
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(),
},
})
type
'legacy' | 'eip1559' | 'eip2930' | undefined
Optional transaction request type to narrow parameters.
import { sendTransaction } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
const result = await sendTransaction(config, {
to: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
type: 'eip1559',
value: parseEther('0.01'),
})
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
Value in wei sent with this transaction.
import { sendTransaction } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
const result = await sendTransaction(config, {
to: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
value: parseEther('0.01'),
})
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 SendTransactionReturnType } from '@wagmi/core'
Transaction hash.
Error
import { type SendTransactionErrorType } from '@wagmi/core'
TanStack Query
import {
type SendTransactionData,
type SendTransactionVariables,
type SendTransactionMutate,
type SendTransactionMutateAsync,
sendTransactionMutationOptions,
} from '@wagmi/core/query'