wallet.useTransfer
Hook for transferring a TIP-20 token via the wallet_transfer JSON-RPC method on the connected wallet.
Usage
ts
import { Hooks } from 'wagmi/tempo'
const transfer = Hooks.wallet.useTransfer()
// Call `mutate` in response to user action (e.g. button click, form submission)
transfer.mutate({
amount: '1.5',
to: '0x20c0000000000000000000000000000000000001',
token: 'pathUSD',
})
console.log('Transaction hash:', transfer.data?.receipt.transactionHash)
// @log: Transaction hash: 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdefts
import { createConfig, http } from 'wagmi'
import { tempo } from 'wagmi/chains'
import { tempoWallet } from 'wagmi/tempo'
export const config = createConfig({
connectors: [tempoWallet()],
chains: [tempo],
multiInjectedProviderDiscovery: false,
transports: {
[tempo.id]: http(),
},
})Editable mode
By default, useTransfer submits the transfer without showing an editable UI.
Pass editable: true to open the wallet's send UI instead, with any supplied fields pre-filled for the user to confirm or edit before signing.
ts
transfer.mutate({
editable: true,
token: 'pathUSD',
})Return Type
See TanStack Query mutation docs for more info hook return types.
data
See Wagmi Action wallet.transfer Return Type
mutate/mutateAsync
See Wagmi Action wallet.transfer Parameters
Parameters
config
Config | undefined
Config to use instead of retrieving from the nearest WagmiProvider.
mutation
See the TanStack Query mutation docs for more info hook parameters.