signTransaction
Action for signing a transaction.
Import
import { signTransaction } from '@wagmi/core'
Usage
import { signTransaction } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
const signature = await signTransaction(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 SignTransactionParameters } from '@wagmi/core'
accessList
AccessList | undefined
The access list.
import { signTransaction } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
const signature = await signTransaction(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 signing a transaction. Throws if account is not found on connector
.
import { signTransaction } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
const signature = await signTransaction(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 signing the transaction.
import { signTransaction } from '@wagmi/core'
import { mainnet } from '@wagmi/core/chains'
import { parseEther } from 'viem'
import { config } from './config'
const signature = await signTransaction(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 sign the transaction with.
- Defaults to current connector.
import { getConnections, signTransaction } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
const connections = getConnections(config)
const signature = await signTransaction(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 { signTransaction } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
const signature = await signTransaction(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, or null
to skip the prelude gas estimation.
import { signTransaction } from '@wagmi/core'
import { parseEther, parseGwei } from 'viem'
import { config } from './config'
const signature = await signTransaction(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 { signTransaction } from '@wagmi/core'
import { parseEther, parseGwei } from 'viem'
import { config } from './config'
const signature = await signTransaction(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 { signTransaction } from '@wagmi/core'
import { parseEther, parseGwei } from 'viem'
import { config } from './config'
const signature = await signTransaction(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 { signTransaction } from '@wagmi/core'
import { parseEther, parseGwei } from 'viem'
import { config } from './config'
const signature = await signTransaction(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 { signTransaction } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
const signature = await signTransaction(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 { signTransaction } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
const signature = await signTransaction(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 { signTransaction } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
const signature = await signTransaction(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 { signTransaction } from '@wagmi/core'
import { parseEther } from 'viem'
import { config } from './config'
const signature = await signTransaction(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 SignTransactionReturnType } from '@wagmi/core'
Transaction hash.
Error
import { type SignTransactionErrorType } from '@wagmi/core'
TanStack Query
import {
type SignTransactionData,
type SignTransactionVariables,
type SignTransactionMutate,
type SignTransactionMutateAsync,
signTransactionMutationOptions,
} from '@wagmi/core/query'