sendTransaction
Action for sending a transaction.
import { sendTransaction } from '@wagmi/core'
Usage
import { sendTransaction, prepareSendTransaction } from '@wagmi/core'
const config = await prepareSendTransaction({
request: { to: 'moxey.eth', value: BigNumber.from('10000000000000000') },
})
const { hash } = await sendTransaction(config)
Return Value
{
hash: `0x${string}`,
wait: (confirmations?: number) => Promise<TransactionReceipt>,
}
Configuration
mode
This is automatically populated when using
prepareSendTransaction
action.
recklesslyUnprepared
: Allow to pass through an adhoc unpreparedrequest
. Note: This has UX pitfalls, it is highly recommended to not use this and instead prepare the request upfront using theprepareSendTransaction
action.prepared
: The request has been prepared with parameters required for sending a transaction via theprepareSendTransaction
action
import { sendTransaction } from '@wagmi/core'
const { sendTransaction } = await sendTransaction({
mode: 'recklesslyUnprepared',
request: {
to: 'moxey.eth',
value: BigNumber.from('10000000000000000'),
},
})
request
This is automatically populated when using
prepareSendTransaction
action.
The request to use when sending the transaction.
import { prepareSendTransaction, sendTransaction } from '@wagmi/core'
const config = await prepareSendTransaction({ ... })
const { hash } = await sendTransaction({
...config,
request: config.request
})
Reckless Usage
It is possible to use sendTransaction
without pairing it with prepareSendTransaction
by using "recklessly unprepared" mode.
💡
This usage is not recommended. It comes with UX pitfalls. Only use it as a last resort.
import { sendTransaction } from '@wagmi/core'
const { hash } = await sendTransaction({
mode: 'recklesslyUnprepared',
to: 'moxey.eth',
value: BigNumber.from('10000000000000000'),
})