Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Provides production-ready Solidity templates for DeFi protocols covering staking, AMMs, governance tokens, and flash loans.
Use this skill ↓70% 83%+13 ptsof test cases passed
Passed 19 of 23 test cases with the skill, and 16 of 23 without it.
3 of 3 safety checks passed
Not used yet
Production-ready templates for common DeFi protocols including staking, AMMs, governance, and flash loans.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract StakingRewards is ReentrancyGuard, Ownable {
IERC20 public stakingToken;
IERC20 public rewardsToken;
uint256 public rewardRate = 100; // Rewards per second
uint256 public lastUpdateTime;
uint256 public rewardPerTokenStored;
mapping(address => uint256) public userRewardPerTokenPaid;
mapping(address => uint256) public rewards;
mapping(address => uint256) public balances;
uint256 private _totalSupply;
event Staked(address indexed user, uint256 amount);
event Withdrawn(address indexed user, uint256 amount);
event RewardPaid(address indexed user, uint256 reward);
constructor(address _stakingToken, address _rewardsToken) {
Published skills whose descriptions closely match this one, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.