thirdweb
thirdweb

⌘K

DocsSupport
TokenStake

StakeERC20

Contract for staking ERC20 tokens, for another ERC20 token as rewards.


thirdweb's ERC20 Staking contract

This contract allows users to stake their ERC-20 tokens and get ERC-20 tokens as staking rewards (different from the staked tokens). Contract admin should set the Staking and Reward token addresses during deployment. These can't be changed later.

Staked tokens are stored inside the contract and rewards are calculated for the amount of time these tokens were staked. Admin should maintain adequate balance of reward tokens in the staking-contract. These rewards are then transferred to stakers upon claiming.

Reward calculation at the time of claiming rewards:

rewardsPerTokenStaked = ((stakingDuration * rewardRatioNumerator) / rewardRatioDenominator) / timeUnit

For e.g., if reward ratio is 1/20, this implies that there will be 1 Reward token given out for every 20 tokens staked. The numerator and denominator of the reward ratio should be set separately (1 and 20 in this case respectively).

Note:

  • Users need to approve their tokens to the staking contract address before they can stake them

  • Contract admin should maintain adequate balance of Reward Tokens in the staking contract -- use the deposit function for depositing reward tokens

1.0.5 Release Notes


Official patch for Multicall disclosed in https://blog.thirdweb.com/vulnerability-report/


DEFAULT_ADMIN_ROLE

(DEFAULT_ADMIN_ROLE)

view

Use this function in your app


import { readContract } from "thirdweb";
const data = await readContract({
contract,
method: "function DEFAULT_ADMIN_ROLE() view returns (bytes32)",
params: []
})

Published by

thirdweb.eth

View all contracts

Details

  • Publish Date

    Dec 18, 2023

  • Audit Report

    View Audit Report

  • Licenses

    Apache-2.0, MIT


  • Extensions

  • Extension detected

    Permissions


  • Share


    Learn about Publish

    Feedback

    Privacy Policy

    Terms of Service

    Gas Estimator

    Chainlist

    Copyright © 2024 thirdweb