sendTransaction
Creates, signs, and sends a new transaction to the network.
Usage
ts
import { sendTransaction } from 'viem'
Usage
ts
import { sendTransaction } from 'viem'
import { walletClient } from '.'
const { hash } = await sendTransaction(walletClient, {
request: {
from: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: 1000000000000000000n
}
})
// { hash: '0x...' }
Returns
'0x${string}'[]
The transaction hash.
Configuration
request
- Type:
TransactionRequest
The transaction request.
ts
const { hash } = await sendTransaction(walletClient, {
request: {
from: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: 1000000000000000000n
}
})
Tips
- For dapps: When using this action, it is assumed that the user has given permission for the dapp to access their accounts via
requestAccounts
. You can also check if the user has granted access to accounts viagetAccounts