Skip to content

Documentation / react-auth / useSendTransaction

Function: useSendTransaction()

useSendTransaction(callbacks?): Object

Use this hook to send a transaction using the embedded wallet and to attach callbacks for success and errors. Transactions sent from the embedded wallet using transaction functions from non-Privy libraries will not trigger the callbacks.

Parameters

callbacks?: Object

callbacks.onError?: (error) => void

Callback that will execute in the case of a non-successful sendTransaction.

ParamPrivyErrorCode - the corresponding error code

callbacks.onSuccess?: (params) => void

Callback that will execute once a successful sendTransaction completes. This will not run for transactions with external wallets.

Param object with the transaction hash

Returns

Object

sendTransaction - prompts the user send a transaction using their embedded wallet

sendTransaction

sendTransaction: (input, options?) => Promise<Object>

Parameters

input: UnsignedTransactionRequest

options?: Object

options.address?: string

options.fundWalletConfig?: FundWalletConfig

options.uiOptions?: SendTransactionModalUIOptions

Returns

Promise<Object>

hash

hash: `0x${string}`