Skip to content

claim

Claim all pending rewards from a specific staking pool.

Usage

example.tsx
import { mintclub } from 'mint.club-v2-sdk'
import { useWalletClient } from 'wagmi'
import { base } from 'viem/chains'
 
function ClaimRewardsExample() {
  const { data: walletClient } = useWalletClient()
 
  const handleClaim = async () => {
    // Check claimable rewards first
    const claimable = await mintclub.network('base').stake.getClaimableReward({
      poolId: 0,
      staker: '0x1234567890123456789012345678901234567890',
    })
 
    const [rewardClaimable] = claimable
    if (rewardClaimable > 0n) {
      await mintclub
        .withWalletClient({
          ...walletClient,
          chain: base,
        } as any)
        .network('base')
        .stake
        .claim({
          poolId: 0,
          onSuccess: (receipt) => {
            console.log('Rewards claimed successfully!', receipt)
          },
          onError: (error) => {
            console.error('Failed to claim rewards:', error)
          },
        })
    }
  }
 
  return <button onClick={handleClaim}>Claim Rewards</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 claim rewards from.

await mintclub.network('base').stake.claim({
  poolId: 0, 
})

onSignatureRequest (optional)

  • Type: onSignatureRequest?: () => void;
  • Default: undefined

Callback function for when the user is requested to sign the transaction.

await mintclub.network('base').stake.claim({
  poolId: 0,
  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.claim({
  poolId: 0,
  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.claim({
  poolId: 0,
  onSuccess: (receipt) => {
    console.log('Rewards claimed 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.claim({
  poolId: 0,
  onError: (error) => {
    console.error('Failed to claim rewards:', error)
  }, 
})