• Core
  • Actions
  • prepareSendTransaction

prepareSendTransaction

Action for preparing a transaction to be sent via sendTransaction.

Eagerly fetches the parameters required for sending a transaction such as the gas estimate and resolving an ENS address (if required).

import { prepareSendTransaction } from '@wagmi/core'

Usage

prepareSendTransaction gives back a "prepared config" to be sent through to sendTransaction.

import { prepareSendTransaction, sendTransaction } from '@wagmi/core'
 
const config = await prepareSendTransaction({
  request: {
    to: 'moxey.eth',
    value: parseEther('1'),
  },
})
const { hash } = await sendTransaction(config)

Return value

{
  mode: 'prepared'
  request: PopulatedTransaction
}

Configuration

request

Request data to prepare the transaction. See TransactionRequest for more info.

import { prepareSendTransaction } from '@wagmi/core'
 
const { config } = await prepareSendTransaction({
  request: {
    to: 'awkweb.eth',
    value: parseEther('1'), // 1 ETH
  },
})

chainId (optional)

Chain ID used to validate if the user is connected to the target chain.

import { prepareSendTransaction } from '@wagmi/core'
 
const { config } = await prepareSendTransaction({
  request: {
    to: 'awkweb.eth',
    value: parseEther('1'), // 1 ETH
  },
  chainId: 1,
})