unstake
Unstake tokens from a specific pool. This will also automatically claim any pending rewards.
Usage
example.tsx
import { mintclub } from 'mint.club-v2-sdk'
import { useWalletClient } from 'wagmi'
import { base } from 'viem/chains'
function UnstakeExample() {
const { data: walletClient } = useWalletClient()
const handleUnstake = async () => {
await mintclub
.withWalletClient({
...walletClient,
chain: base,
} as any)
.network('base')
.stake
.unstake({
poolId: 0,
amount: BigInt('50000000000000000'), // 0.05 token (18 decimals)
onSuccess: (receipt) => {
console.log('Tokens unstaked successfully!', receipt)
},
onError: (error) => {
console.error('Failed to unstake tokens:', error)
},
})
}
return <button onClick={handleUnstake}>Unstake Tokens</button>
}Return Value
Promise<TransactionReceipt>
Returns a promise that resolves to a TransactionReceipt object when the transaction is successful.
Parameters
poolId
- Type:
number
The ID of the staking pool to unstake tokens from.
await mintclub.network('base').stake.unstake({
poolId: 0,
amount: BigInt('50000000000000000'),
})amount
- Type:
bigint
The amount of tokens to unstake.
await mintclub.network('base').stake.unstake({
poolId: 0,
amount: BigInt('50000000000000000'),
})onSignatureRequest (optional)
- Type:
onSignatureRequest?: () => void; - Default:
undefined
Callback function for when the user is requested to sign the transaction.
await mintclub.network('base').stake.unstake({
poolId: 0,
amount: BigInt('50000000000000000'),
onSignatureRequest: () => {
console.log('Please sign the transaction')
},
})onSigned (optional)
- Type:
onSigned?: (txHash: '0x${string}') => void; - Default:
undefined
Callback function for when the user signs the transaction.
await mintclub.network('base').stake.unstake({
poolId: 0,
amount: BigInt('50000000000000000'),
onSigned: (txHash) => {
console.log('Transaction signed:', txHash)
},
})onSuccess (optional)
- Type:
onSuccess?: (receipt: TransactionReceipt) => void; - Default:
undefined
Callback function for when the transaction is successful.
await mintclub.network('base').stake.unstake({
poolId: 0,
amount: BigInt('50000000000000000'),
onSuccess: (receipt) => {
console.log('Tokens unstaked successfully!', 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('base').stake.unstake({
poolId: 0,
amount: BigInt('50000000000000000'),
onError: (error) => {
console.error('Failed to unstake tokens:', error)
},
})