⛏️claimRewards

Description

The claimRewards function allows a user to claim their rewards from a reward pool for a specific stake.

Parameters

NameTypeDescription

stakeId

number

The ID of the stake for which the user wants to claim rewards

amount

string

The amount of rewards the user wants to claim. The amount should be in ether format, such as '0.01'.

privateKey

string

The private key of the user's wallet.

Response

PropertyTypeDescription

receipt

object

The receipt object that contains the transaction hash and other details of the transaction that claimed rewards.

Example Request and Response

Prerequisites

Before making requests with Nest SDK, you must have it installed.

You can install Nest SDK using either npm or yarn. Use the following commands to install Nest SDK:

npm install @nest25/tokenomics-lib
OR
yarn add @nest25/tokenomics-lib

Request

Here is an example of how to make a claimRewards request using the Nest SDK:

// import Nest SDK library
const { rewards } = require('@nest25/tokenomics-lib');

// create a new instance of the rewards class
const Rewards = new rewards();

async function main() {
  // claim rewards for a given user and amount
  const result = await Rewards.claimRewards(49, '0.3', TEST_PRIVATE_KEY);
  // log the result
  console.log(result);
}
main();

Response

 {
        type: 2,
        chainId: 8888,
        nonce: 4,
        maxPriorityFeePerGas: BigNumber { _hex: '0x59682f00', _isBigNumber: true },
        maxFeePerGas: BigNumber { _hex: '0xd09dc300', _isBigNumber: true },
        gasPrice: null,
        gasLimit: BigNumber { _hex: '0x016917', _isBigNumber: true },
        to: '0x5A98631C9Bb0a2139D70986D96F51E5872CEF5b9',
        value: BigNumber { _hex: '0x00', _isBigNumber: true },
        data: '0x594dd43200000000000000000000000000000000000000000000000000000000000000310000000000000000000000000000000000000000000000000429d069189e0000',
        accessList: [],
        hash: '0x58c18fe9f282ab015d3826f91cb0a1c5b3bc141793c9da1c1947aa40dc93a6f5',
        v: 0,
        r: '0xc93fa73f99a4ca2a54dd0c1aba9d77b2fa9003665525e898b34ec13ac102f1ac',
        s: '0x01eddbc9f1b11be8d4042dce811cf3a7f205ee74710ec9db061733e800f0ba9a',
        from: '0x87658a6c698D1392d45B0AB756F969361AcB912d',
        confirmations: 0,
        wait: [Function (anonymous)]
      }

Use Cases

  • Crypto Staking Platforms: The claimRewards function can be used by crypto staking platforms to allow users to claim their rewards from the reward pool for their specific stake.

  • Decentralized Finance (DeFi) Applications: The function can be used by DeFi applications that offer staking as one of their services, allowing users to claim their rewards from the reward pool.

  • Crypto Wallets: The claimRewards function can be used by crypto wallets that support staking to enable their users to claim their rewards.

Last updated