I am writing a sort of staking contract, where people can stake my ERC20 token, and get rewarded in the same token.

My contract is working with 2 address.

  1. Stake address - where I put all the staked tokens
  2. Reward address - where I put the tokens to be used as a reward.

When users claim the reward, the contract calls transferFrom(rewardAddress, userAddress, reward)

I'd like to know how I can possible arrange my reward address to grant unlimited allowance/approval for the contract to spend its tokens. Is there a standard/best practice for this? Do I have to manually set an allowance behind the scenes?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.