transfer
Transfers tokens to another user.
Usage
example.tsx
import { mintclub, wei } from 'mint.club-v2-sdk'
import { useWalletClient } from 'wagmi'
import { base } from 'viem/chains'
function TransferExample() {
const { data: walletClient } = useWalletClient()
const handleTransfer = async () => {
await mintclub
.withWalletClient({
...walletClient,
chain: base,
} as any)
.network('base')
.token('SYMBOL')
.transfer({
amount: wei(1, 18),
recipient: '0x...',
})
}
return <button onClick={handleTransfer}>Transfer Tokens</button>
}Return Value
Promise<TransactionReceipt>
Returns a promise that resolves to a TransactionReceipt object when the transaction is successful.
Parameters
amount
- Type:
bigint
Amount to transfer
example.ts
import { mintclub, wei } from 'mint.club-v2-sdk'
await mintclub
.network('ethereum')
.token('SYMBOL')
.transfer({
amount: wei(1, 18),
recipient: '0x...',
})recipient
- Type:
'0x...${string}'
The address of the recipient
example.ts
import { mintclub, wei } from 'mint.club-v2-sdk'
await mintclub
.network('ethereum')
.token('SYMBOL')
.transfer({
amount: wei(1, 18),
recipient: '0x...',
})onSignatureRequest (optional)
- Type:
onSignatureRequest?: () => void; - Default:
undefined
Callback function for when the user is requested to sign the transaction.
await mintclub
.network('ethereum')
.token('MINT')
.transfer({
amount: wei(1, 18),
recipient: '0x...'
onSignatureRequest: () => {}
})onSigned (optional)
- Type:
onSigned?: (txHash: '0x${string}') => void; - Default:
undefined
Callback function for when the user is signs the transaction.
await mintclub
.network('ethereum')
.token('MINT')
.transfer({
amount: wei(1, 18),
recipient: '0x...'
onSigned: (txHash) => {}
})onSuccess (optional)
- Type:
onSuccess?: (receipt: TransactionReceipt) => void; - Default:
undefined
Callback function for when the transaction is successful.
await mintclub
.network('ethereum')
.token('MINT')
.transfer({
amount: wei(1, 18),
recipient: '0x...'
onSuccess: (receipt) => {}
})onError (optional)
- Type:
onError?: (error: unknown) => void; - Default:
undefined
Callback function for when the transaction fails. This also includes when the user rejects the transaction.
await mintclub
.network('ethereum')
.token('MINT')
.transfer({
amount: wei(1, 18),
recipient: '0x...'
onError: (error) => {}
})