More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 2,100 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Unstake | 21048497 | 25 days ago | IN | 0 ETH | 0.00033014 | ||||
Claim | 21048480 | 25 days ago | IN | 0 ETH | 0.00021937 | ||||
Unstake | 21004377 | 31 days ago | IN | 0 ETH | 0.00046576 | ||||
Unstake | 20933393 | 41 days ago | IN | 0 ETH | 0.00074212 | ||||
Claim | 20933386 | 41 days ago | IN | 0 ETH | 0.00041387 | ||||
Unstake | 20911457 | 44 days ago | IN | 0 ETH | 0.00053035 | ||||
Claim | 20911451 | 44 days ago | IN | 0 ETH | 0.00032461 | ||||
Unstake | 20853457 | 52 days ago | IN | 0 ETH | 0.00044972 | ||||
Unstake | 20823549 | 56 days ago | IN | 0 ETH | 0.00102559 | ||||
Unstake | 20818622 | 57 days ago | IN | 0 ETH | 0.00120939 | ||||
Unstake | 20817772 | 57 days ago | IN | 0 ETH | 0.0010464 | ||||
Claim | 20817768 | 57 days ago | IN | 0 ETH | 0.00066135 | ||||
Unstake | 20815211 | 57 days ago | IN | 0 ETH | 0.0014617 | ||||
Unstake | 20813539 | 58 days ago | IN | 0 ETH | 0.00146219 | ||||
Unstake | 20813538 | 58 days ago | IN | 0 ETH | 0.00071371 | ||||
Claim | 20813533 | 58 days ago | IN | 0 ETH | 0.0009848 | ||||
Unstake | 20813533 | 58 days ago | IN | 0 ETH | 0.0010056 | ||||
Stake | 20811133 | 58 days ago | IN | 0 ETH | 0.00135959 | ||||
Stake | 20811111 | 58 days ago | IN | 0 ETH | 0.00117522 | ||||
Unstake | 20811070 | 58 days ago | IN | 0 ETH | 0.00110195 | ||||
Unstake | 20811059 | 58 days ago | IN | 0 ETH | 0.00102364 | ||||
Unstake | 20807556 | 58 days ago | IN | 0 ETH | 0.0013397 | ||||
Claim | 20807537 | 58 days ago | IN | 0 ETH | 0.0009469 | ||||
Unstake | 20804628 | 59 days ago | IN | 0 ETH | 0.00098345 | ||||
Claim | 20804625 | 59 days ago | IN | 0 ETH | 0.00058694 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
21183853 | 6 days ago | 0.00001833 ETH | ||||
21164263 | 9 days ago | 0.00000466 ETH | ||||
21109542 | 16 days ago | 0.0000083 ETH | ||||
21097465 | 18 days ago | 0.00001124 ETH | ||||
21087227 | 19 days ago | 0.00021547 ETH | ||||
21087092 | 19 days ago | 0.00008111 ETH | ||||
21078191 | 21 days ago | 0.00000586 ETH | ||||
21059372 | 23 days ago | 0.00000684 ETH | ||||
21048480 | 25 days ago | 0.00404548 ETH | ||||
21047296 | 25 days ago | 0.00001666 ETH | ||||
21039655 | 26 days ago | 0.00001217 ETH | ||||
21039581 | 26 days ago | 0.00001527 ETH | ||||
21030908 | 27 days ago | 0.00001961 ETH | ||||
21030890 | 27 days ago | 0.00008597 ETH | ||||
21026050 | 28 days ago | 0.00010193 ETH | ||||
21019764 | 29 days ago | 0.00000783 ETH | ||||
21018669 | 29 days ago | 0.00001227 ETH | ||||
21015605 | 29 days ago | 0.00000702 ETH | ||||
21004377 | 31 days ago | 0.00401061 ETH | ||||
20977427 | 35 days ago | 0.00000376 ETH | ||||
20967632 | 36 days ago | 0.00014274 ETH | ||||
20940120 | 40 days ago | 0.00001086 ETH | ||||
20939794 | 40 days ago | 0.00010247 ETH | ||||
20939428 | 40 days ago | 0.00000638 ETH | ||||
20937976 | 40 days ago | 0.00000479 ETH |
Loading...
Loading
Contract Name:
TokenStaking
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.20; /* ┌─────────────────────────────────────────────────────────────────────────┐ │ │ │ _______ ______ _ │ │ |__ __| | ____| (_) │ │ | | __ ___ _| |__ __ _ _ __ _ __ ___ _ _ __ __ _ │ │ | |/ _` \ \/ / __/ _` | '__| '_ ` _ \ | | '_ \ / _` | │ │ | | (_| |> <| | | (_| | | | | | | | | | | | | | (_| | │ │ |_|\__,_/_/\_\_| \__,_|_| |_| |_| |_|(_)_|_| |_|\__, | │ │ __/ | │ │ |___/ │ │ │ │ taxfarm.ing │ │ │ └─────────────────────────────────────────────────────────────────────────┘ */ import {IERC20} from "./utils/IERC20.sol"; contract TokenStaking { IERC20 public taxFarmingToken; uint public totalStaked; // total token staked uint public totalRewards; // total rewards received by the contract uint private accumulatedRewardsPerToken = 1; // act as a price entry for new staker, the delta between this variable entry and exit is the effective rewards per token uint private constant DECIMALS = 1e12; // floor precision protection decimals struct Stake { uint tokensStaked; uint accumulatedRewardsPerToken; } mapping (address => Stake) public stakersInfos; mapping (address => uint) public lastTx; // last tx block of stakers, used to avoid reentrancy and flashloans attacks event TokenStaked(address indexed user, uint amount, uint accumulatedRewardsPerToken); event TokenUnstaked(address indexed user, uint amount, uint accumulatedRewardsPerToken); constructor(address _taxFarmingToken) { taxFarmingToken = IERC20(_taxFarmingToken); } // prevent user to use any function again in this block modifier blockUser(address user) { require(lastTx[user] != block.number, "User blocked"); lastTx[user] = block.number; _; } function stake(uint amount) external blockUser(msg.sender) { if (amount == 0) return; address user = msg.sender; if (stakersInfos[user].tokensStaked == 0) stakersInfos[user].accumulatedRewardsPerToken = accumulatedRewardsPerToken; else _claim(user); taxFarmingToken.transferFrom(user, address(this), amount); totalStaked += amount; stakersInfos[user].tokensStaked += amount; emit TokenStaked(user, amount, accumulatedRewardsPerToken); } function unstake(uint amount) external blockUser(msg.sender) { address user = msg.sender; if (amount == 0 || stakersInfos[user].tokensStaked == 0) return; _claim(user); require(stakersInfos[user].tokensStaked >= amount, "Not enough staked tokens"); stakersInfos[user].tokensStaked -= amount; totalStaked -= amount; taxFarmingToken.transfer(user, amount); emit TokenUnstaked(user, amount, accumulatedRewardsPerToken); } function claim() external blockUser(msg.sender) { _claim(msg.sender); } function _claim(address user) private { uint rewards = getUserRewards(user); stakersInfos[user].accumulatedRewardsPerToken = accumulatedRewardsPerToken; if (rewards == 0) return; (bool success, ) = payable(user).call{value: rewards}(""); require(success, "Unable to claim rewards"); } function getUserRewards(address user) public view returns (uint) { uint rewardsPerToken = accumulatedRewardsPerToken - stakersInfos[user].accumulatedRewardsPerToken; uint rewards = (rewardsPerToken * stakersInfos[user].tokensStaked) / DECIMALS; return rewards; } receive() payable external { require(totalStaked != 0, "No stakers"); uint rewardsPerToken = (msg.value * DECIMALS) / totalStaked; accumulatedRewardsPerToken += rewardsPerToken; totalRewards += msg.value; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); function burn(uint256 value) external; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); }
{ "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_taxFarmingToken","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"accumulatedRewardsPerToken","type":"uint256"}],"name":"TokenStaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"accumulatedRewardsPerToken","type":"uint256"}],"name":"TokenUnstaked","type":"event"},{"inputs":[],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getUserRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastTx","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stakersInfos","outputs":[{"internalType":"uint256","name":"tokensStaked","type":"uint256"},{"internalType":"uint256","name":"accumulatedRewardsPerToken","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"taxFarmingToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalStaked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
6080604052600160035534801561001557600080fd5b506040516109a23803806109a283398101604081905261003491610059565b600080546001600160a01b0319166001600160a01b0392909216919091179055610089565b60006020828403121561006b57600080fd5b81516001600160a01b038116811461008257600080fd5b9392505050565b61090a806100986000396000f3fe60806040526004361061008a5760003560e01c80634e71d92d116100595780634e71d92d146101cf5780637931cef5146101e4578063817b1cd21461022d578063a62b48ce14610243578063a694fc3a1461027057600080fd5b8063078b0fb71461012c5780630e15561a1461015f5780632e17de781461017557806342a9763f1461019757600080fd5b36610127576001546000036100d35760405162461bcd60e51b815260206004820152600a6024820152694e6f207374616b65727360b01b60448201526064015b60405180910390fd5b6001546000906100e864e8d4a51000346107de565b6100f291906107fb565b90508060036000828254610106919061081d565b92505081905550346002600082825461011f919061081d565b925050819055005b600080fd5b34801561013857600080fd5b5061014c610147366004610830565b610290565b6040519081526020015b60405180910390f35b34801561016b57600080fd5b5061014c60025481565b34801561018157600080fd5b50610195610190366004610860565b6102fa565b005b3480156101a357600080fd5b506000546101b7906001600160a01b031681565b6040516001600160a01b039091168152602001610156565b3480156101db57600080fd5b506101956104f5565b3480156101f057600080fd5b506102186101ff366004610830565b6004602052600090815260409020805460019091015482565b60408051928352602083019190915201610156565b34801561023957600080fd5b5061014c60015481565b34801561024f57600080fd5b5061014c61025e366004610830565b60056020526000908152604090205481565b34801561027c57600080fd5b5061019561028b366004610860565b61054b565b6001600160a01b03811660009081526004602052604081206001015460035482916102ba91610879565b6001600160a01b0384166000908152600460205260408120549192509064e8d4a51000906102e890846107de565b6102f291906107fb565b949350505050565b336000818152600560205260409020544390036103295760405162461bcd60e51b81526004016100ca9061088c565b6001600160a01b03811660009081526005602052604090204390553382158061036857506001600160a01b038116600090815260046020526040902054155b1561037257505050565b61037b816106e5565b6001600160a01b0381166000908152600460205260409020548311156103e35760405162461bcd60e51b815260206004820152601860248201527f4e6f7420656e6f756768207374616b656420746f6b656e73000000000000000060448201526064016100ca565b6001600160a01b0381166000908152600460205260408120805485929061040b908490610879565b9250508190555082600160008282546104249190610879565b909155505060005460405163a9059cbb60e01b81526001600160a01b038381166004830152602482018690529091169063a9059cbb906044016020604051808303816000875af115801561047c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104a091906108b2565b50806001600160a01b03167f563fc70fca9d440d883299c76a721644d5aca7c45df98aeb5292c4cb823579bf846003546040516104e7929190918252602082015260400190565b60405180910390a2505b5050565b336000818152600560205260409020544390036105245760405162461bcd60e51b81526004016100ca9061088c565b6001600160a01b0381166000908152600560205260409020439055610548336106e5565b50565b3360008181526005602052604090205443900361057a5760405162461bcd60e51b81526004016100ca9061088c565b6001600160a01b038116600090815260056020526040902043905581156104f1573360008181526004602052604081205490036105d5576003546001600160a01b0382166000908152600460205260409020600101556105de565b6105de816106e5565b6000546040516323b872dd60e01b81526001600160a01b03838116600483015230602483015260448201869052909116906323b872dd906064016020604051808303816000875af1158015610637573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061065b91906108b2565b50826001600082825461066e919061081d565b90915550506001600160a01b0381166000908152600460205260408120805485929061069b90849061081d565b90915550506003546040516001600160a01b038316917f6173e4d2d9dd52aae0ed37afed3adcf924a490639b759ca93d32dc43366c17d2916104e791878252602082015260400190565b60006106f082610290565b6003546001600160a01b038416600090815260046020526040812060010191909155909150819003610720575050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461076d576040519150601f19603f3d011682016040523d82523d6000602084013e610772565b606091505b50509050806107c35760405162461bcd60e51b815260206004820152601760248201527f556e61626c6520746f20636c61696d207265776172647300000000000000000060448201526064016100ca565b505050565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176107f5576107f56107c8565b92915050565b60008261081857634e487b7160e01b600052601260045260246000fd5b500490565b808201808211156107f5576107f56107c8565b60006020828403121561084257600080fd5b81356001600160a01b038116811461085957600080fd5b9392505050565b60006020828403121561087257600080fd5b5035919050565b818103818111156107f5576107f56107c8565b6020808252600c908201526b155cd95c88189b1bd8dad95960a21b604082015260600190565b6000602082840312156108c457600080fd5b8151801515811461085957600080fdfea2646970667358221220a88c3528b9b5a5085b5b8035d04c4b45f8049da14900160eb5a2df61bbaba15a64736f6c634300081400330000000000000000000000006db6fdb5182053eecec778afec95e0814172a474
Deployed Bytecode
0x60806040526004361061008a5760003560e01c80634e71d92d116100595780634e71d92d146101cf5780637931cef5146101e4578063817b1cd21461022d578063a62b48ce14610243578063a694fc3a1461027057600080fd5b8063078b0fb71461012c5780630e15561a1461015f5780632e17de781461017557806342a9763f1461019757600080fd5b36610127576001546000036100d35760405162461bcd60e51b815260206004820152600a6024820152694e6f207374616b65727360b01b60448201526064015b60405180910390fd5b6001546000906100e864e8d4a51000346107de565b6100f291906107fb565b90508060036000828254610106919061081d565b92505081905550346002600082825461011f919061081d565b925050819055005b600080fd5b34801561013857600080fd5b5061014c610147366004610830565b610290565b6040519081526020015b60405180910390f35b34801561016b57600080fd5b5061014c60025481565b34801561018157600080fd5b50610195610190366004610860565b6102fa565b005b3480156101a357600080fd5b506000546101b7906001600160a01b031681565b6040516001600160a01b039091168152602001610156565b3480156101db57600080fd5b506101956104f5565b3480156101f057600080fd5b506102186101ff366004610830565b6004602052600090815260409020805460019091015482565b60408051928352602083019190915201610156565b34801561023957600080fd5b5061014c60015481565b34801561024f57600080fd5b5061014c61025e366004610830565b60056020526000908152604090205481565b34801561027c57600080fd5b5061019561028b366004610860565b61054b565b6001600160a01b03811660009081526004602052604081206001015460035482916102ba91610879565b6001600160a01b0384166000908152600460205260408120549192509064e8d4a51000906102e890846107de565b6102f291906107fb565b949350505050565b336000818152600560205260409020544390036103295760405162461bcd60e51b81526004016100ca9061088c565b6001600160a01b03811660009081526005602052604090204390553382158061036857506001600160a01b038116600090815260046020526040902054155b1561037257505050565b61037b816106e5565b6001600160a01b0381166000908152600460205260409020548311156103e35760405162461bcd60e51b815260206004820152601860248201527f4e6f7420656e6f756768207374616b656420746f6b656e73000000000000000060448201526064016100ca565b6001600160a01b0381166000908152600460205260408120805485929061040b908490610879565b9250508190555082600160008282546104249190610879565b909155505060005460405163a9059cbb60e01b81526001600160a01b038381166004830152602482018690529091169063a9059cbb906044016020604051808303816000875af115801561047c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104a091906108b2565b50806001600160a01b03167f563fc70fca9d440d883299c76a721644d5aca7c45df98aeb5292c4cb823579bf846003546040516104e7929190918252602082015260400190565b60405180910390a2505b5050565b336000818152600560205260409020544390036105245760405162461bcd60e51b81526004016100ca9061088c565b6001600160a01b0381166000908152600560205260409020439055610548336106e5565b50565b3360008181526005602052604090205443900361057a5760405162461bcd60e51b81526004016100ca9061088c565b6001600160a01b038116600090815260056020526040902043905581156104f1573360008181526004602052604081205490036105d5576003546001600160a01b0382166000908152600460205260409020600101556105de565b6105de816106e5565b6000546040516323b872dd60e01b81526001600160a01b03838116600483015230602483015260448201869052909116906323b872dd906064016020604051808303816000875af1158015610637573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061065b91906108b2565b50826001600082825461066e919061081d565b90915550506001600160a01b0381166000908152600460205260408120805485929061069b90849061081d565b90915550506003546040516001600160a01b038316917f6173e4d2d9dd52aae0ed37afed3adcf924a490639b759ca93d32dc43366c17d2916104e791878252602082015260400190565b60006106f082610290565b6003546001600160a01b038416600090815260046020526040812060010191909155909150819003610720575050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461076d576040519150601f19603f3d011682016040523d82523d6000602084013e610772565b606091505b50509050806107c35760405162461bcd60e51b815260206004820152601760248201527f556e61626c6520746f20636c61696d207265776172647300000000000000000060448201526064016100ca565b505050565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176107f5576107f56107c8565b92915050565b60008261081857634e487b7160e01b600052601260045260246000fd5b500490565b808201808211156107f5576107f56107c8565b60006020828403121561084257600080fd5b81356001600160a01b038116811461085957600080fd5b9392505050565b60006020828403121561087257600080fd5b5035919050565b818103818111156107f5576107f56107c8565b6020808252600c908201526b155cd95c88189b1bd8dad95960a21b604082015260600190565b6000602082840312156108c457600080fd5b8151801515811461085957600080fdfea2646970667358221220a88c3528b9b5a5085b5b8035d04c4b45f8049da14900160eb5a2df61bbaba15a64736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000006db6fdb5182053eecec778afec95e0814172a474
-----Decoded View---------------
Arg [0] : _taxFarmingToken (address): 0x6dB6FDb5182053EECeC778aFec95E0814172A474
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000006db6fdb5182053eecec778afec95e0814172a474
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
ETH | Ether (ETH) | 100.00% | $3,108.2 | 2.3906 | $7,430.6 |
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.