Address Contract Partially Verified
Address
0x12E951934246186F50146235d541D3bD1D463E4d
Balance
0 ETH
Nonce
1
Code Size
8276 bytes
Creator
0x4103D1bC...12df at tx 0x6a0650be...bf570d
Indexed Transactions
0
Contract Bytecode
8276 bytes
0x608060405234801561001057600080fd5b50600436106101215760003560e01c806339509351116100ad578063986f7b1511610071578063986f7b15146102e6578063a0712d6814610304578063a457c2d714610320578063a9059cbb14610350578063dd62ed3e1461038057610121565b806339509351146102545780633d18b912146102845780633dda3da71461028e57806370a082311461029857806395d89b41146102c857610121565b806323b872dd116100f457806323b872dd146101b0578063293be456146101e05780632d53d984146101fc578063313ce5671461021857806334f2015d1461023657610121565b8063046363491461012657806306fdde0314610144578063095ea7b31461016257806318160ddd14610192575b600080fd5b61012e6103b0565b60405161013b919061150b565b60405180910390f35b61014c6103fe565b60405161015991906115bf565b60405180910390f35b61017c60048036038101906101779190611670565b610490565b60405161018991906116cb565b60405180910390f35b61019a6104ae565b6040516101a7919061150b565b60405180910390f35b6101ca60048036038101906101c591906116e6565b6104b8565b6040516101d791906116cb565b60405180910390f35b6101fa60048036038101906101f59190611739565b6105b9565b005b61021660048036038101906102119190611739565b610622565b005b61022061082a565b60405161022d9190611782565b60405180910390f35b61023e610833565b60405161024b919061150b565b60405180910390f35b61026e60048036038101906102699190611670565b61083d565b60405161027b91906116cb565b60405180910390f35b61028c6108e9565b005b610296610ad7565b005b6102b260048036038101906102ad919061179d565b610c52565b6040516102bf919061150b565b60405180910390f35b6102d0610c9b565b6040516102dd91906115bf565b60405180910390f35b6102ee610d2d565b6040516102fb919061150b565b60405180910390f35b61031e60048036038101906103199190611739565b610d37565b005b61033a60048036038101906103359190611670565b610daa565b60405161034791906116cb565b60405180910390f35b61036a60048036038101906103659190611670565b610e9e565b60405161037791906116cb565b60405180910390f35b61039a600480360381019061039591906117ca565b610ebc565b6040516103a7919061150b565b60405180910390f35b6000600360006103be610f43565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905090565b60606008805461040d90611839565b80601f016020809104026020016040519081016040528092919081815260200182805461043990611839565b80156104865780601f1061045b57610100808354040283529160200191610486565b820191906000526020600020905b81548152906001019060200180831161046957829003601f168201915b5050505050905090565b60006104a461049d610f43565b8484610f4b565b6001905092915050565b6000600754905090565b60006104c5848484611116565b6000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610510610f43565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610590576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610587906118dd565b60405180910390fd5b6105ad8561059c610f43565b85846105a8919061192c565b610f4b565b60019150509392505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166105f8610f43565b73ffffffffffffffffffffffffffffffffffffffff161461061857600080fd5b8060018190555050565b806005600061062f610f43565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410156106ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106a2906119ac565b60405180910390fd5b6000600360006106b9610f43565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414610734576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161072b90611a18565b60405180910390fd5b8060036000610741610f43565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550426004600061078c610f43565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555080600560006107d7610f43565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610820919061192c565b9250508190555050565b60006012905090565b6000600154905090565b60006108df61084a610f43565b848460066000610858610f43565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546108da9190611a38565b610f4b565b6001905092915050565b600254426108f7919061192c565b60046000610903610f43565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054111561097f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161097690611b00565b60405180910390fd5b6000670de0b6b3a764000060015460036000610999610f43565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546109de9190611b20565b6109e89190611ba9565b90506000600254600460006109fb610f43565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205442610a41919061192c565b610a4b9190611ba9565b905060025481610a5b9190611b20565b60046000610a67610f43565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610ab09190611a38565b92505081905550610ad3610ac2610f43565b8284610ace9190611b20565b611398565b5050565b600060036000610ae5610f43565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610b61576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b5890611c26565b60405180910390fd5b60036000610b6d610f43565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460056000610bb4610f43565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610bfd9190611a38565b92505081905550600060036000610c12610f43565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550565b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060098054610caa90611839565b80601f0160208091040260200160405190810160405280929190818152602001828054610cd690611839565b8015610d235780601f10610cf857610100808354040283529160200191610d23565b820191906000526020600020905b815481529060010190602001808311610d0657829003601f168201915b5050505050905090565b6000600254905090565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610d76610f43565b73ffffffffffffffffffffffffffffffffffffffff1614610d9657600080fd5b610da7610da1610f43565b82611398565b50565b60008060066000610db9610f43565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610e76576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e6d90611cb8565b60405180910390fd5b610e93610e81610f43565b858584610e8e919061192c565b610f4b565b600191505092915050565b6000610eb2610eab610f43565b8484611116565b6001905092915050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610fbb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fb290611d4a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561102b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161102290611ddc565b60405180910390fd5b80600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051611109919061150b565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611186576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161117d90611e6e565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156111f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111ed90611f00565b60405180910390fd5b6112018383836114ed565b6000600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611288576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161127f90611f92565b60405180910390fd5b8181611294919061192c565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546113269190611a38565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161138a919061150b565b60405180910390a350505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611408576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113ff90611ffe565b60405180910390fd5b611414600083836114ed565b80600760008282546114269190611a38565b9250508190555080600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461147c9190611a38565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516114e1919061150b565b60405180910390a35050565b505050565b6000819050919050565b611505816114f2565b82525050565b600060208201905061152060008301846114fc565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015611560578082015181840152602081019050611545565b8381111561156f576000848401525b50505050565b6000601f19601f8301169050919050565b600061159182611526565b61159b8185611531565b93506115ab818560208601611542565b6115b481611575565b840191505092915050565b600060208201905081810360008301526115d98184611586565b905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000611611826115e6565b9050919050565b61162181611606565b811461162c57600080fd5b50565b60008135905061163e81611618565b92915050565b61164d816114f2565b811461165857600080fd5b50565b60008135905061166a81611644565b92915050565b60008060408385031215611687576116866115e1565b5b60006116958582860161162f565b92505060206116a68582860161165b565b9150509250929050565b60008115159050919050565b6116c5816116b0565b82525050565b60006020820190506116e060008301846116bc565b92915050565b6000806000606084860312156116ff576116fe6115e1565b5b600061170d8682870161162f565b935050602061171e8682870161162f565b925050604061172f8682870161165b565b9150509250925092565b60006020828403121561174f5761174e6115e1565b5b600061175d8482850161165b565b91505092915050565b600060ff82169050919050565b61177c81611766565b82525050565b60006020820190506117976000830184611773565b92915050565b6000602082840312156117b3576117b26115e1565b5b60006117c18482850161162f565b91505092915050565b600080604083850312156117e1576117e06115e1565b5b60006117ef8582860161162f565b92505060206118008582860161162f565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061185157607f821691505b602082108114156118655761186461180a565b5b50919050565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b60006118c7602883611531565b91506118d28261186b565b604082019050919050565b600060208201905081810360008301526118f6816118ba565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000611937826114f2565b9150611942836114f2565b925082821015611955576119546118fd565b5b828203905092915050565b7f4352493a204e6f7420656e6f7567682062616c616e6365000000000000000000600082015250565b6000611996601783611531565b91506119a182611960565b602082019050919050565b600060208201905081810360008301526119c581611989565b9050919050565b7f4352493a204d75737420656d707479207374616b652066697273740000000000600082015250565b6000611a02601b83611531565b9150611a0d826119cc565b602082019050919050565b60006020820190508181036000830152611a31816119f5565b9050919050565b6000611a43826114f2565b9150611a4e836114f2565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115611a8357611a826118fd565b5b828201905092915050565b7f4352493a206e65656420746f206b656570207374616b6520666f72206174206c60008201527f656173742061206461792e000000000000000000000000000000000000000000602082015250565b6000611aea602b83611531565b9150611af582611a8e565b604082019050919050565b60006020820190508181036000830152611b1981611add565b9050919050565b6000611b2b826114f2565b9150611b36836114f2565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611b6f57611b6e6118fd565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000611bb4826114f2565b9150611bbf836114f2565b925082611bcf57611bce611b7a565b5b828204905092915050565b7f4352493a20456d707479207374616b6500000000000000000000000000000000600082015250565b6000611c10601083611531565b9150611c1b82611bda565b602082019050919050565b60006020820190508181036000830152611c3f81611c03565b9050919050565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b6000611ca2602583611531565b9150611cad82611c46565b604082019050919050565b60006020820190508181036000830152611cd181611c95565b9050919050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000611d34602483611531565b9150611d3f82611cd8565b604082019050919050565b60006020820190508181036000830152611d6381611d27565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b6000611dc6602283611531565b9150611dd182611d6a565b604082019050919050565b60006020820190508181036000830152611df581611db9565b9050919050565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b6000611e58602583611531565b9150611e6382611dfc565b604082019050919050565b60006020820190508181036000830152611e8781611e4b565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b6000611eea602383611531565b9150611ef582611e8e565b604082019050919050565b60006020820190508181036000830152611f1981611edd565b9050919050565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b6000611f7c602683611531565b9150611f8782611f20565b604082019050919050565b60006020820190508181036000830152611fab81611f6f565b9050919050565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b6000611fe8601f83611531565b9150611ff382611fb2565b602082019050919050565b6000602082019050818103600083015261201781611fdb565b905091905056fea26469706673582212208893b2f7ab108e056f1797fb06e939624df48e97571fe0150e963ed10d04c27564736f6c63430008090033
Verified Source Code Partial Match
Compiler: v0.8.9+commit.e5eed63a
EVM: london
Optimization: No
CRI.sol 543 lines
// SPDX-License-Identifier: MIT
// File: @openzeppelin/contracts/utils/Context.sol
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol
pragma solidity ^0.8.0;
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
// File: token.sol
// contracts/SimpleToken.sol
pragma solidity ^0.8.7;
/**
* @title CRI
* @dev CRI is the token for Crypto International
* All rights reserved by Crypto International Inc.
*/
contract CRI is Context, IERC20, IERC20Metadata {
address private _owner;
uint256 private _reward;
uint256 private _reward_period;
mapping (address => uint256) private _stakes;
mapping (address => uint256) private _stake_ts;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Constructor that gives _msgSender() all of existing tokens.
*
* - `initialSupply` and `initialReward` should have the unit of 1e-18.
*
*/
constructor (
string memory name_,
string memory symbol_,
uint256 initialSupply,
uint256 initialReward,
uint32 rewardPeriod
) {
_name = name_;
_symbol = symbol_;
_reward = initialReward;
_reward_period = rewardPeriod;
_owner = _msgSender();
_mint(_msgSender(), initialSupply);
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
/**
* @dev adjusts the per-day reward value per token.
*
* - `reward` should have the unit of 1e-18
*
*/
function setReward(uint256 reward) public {
require(_msgSender() == _owner);
_reward = reward;
}
/**
* @dev mints new tokens.
*
* - `amount` specifies amount of tokens to be minted (in 1e-18).
*
*/
function mint(uint256 amount) public {
require(_msgSender() == _owner);
_mint(_msgSender(), amount);
}
/**
* @dev rewards sender rewards for holding their tokens.
*
* CRI wallets can choose to obtain daily reward for tokens they are
* currently holding. Wallet holders can specify any amount equals to or
* below their balance to get reward for. Please note that by getting
* reward, the specified portion of their balance will be locked.
*
*/
function getReward() public {
require(_stake_ts[_msgSender()] <= block.timestamp - _reward_period, "CRI: need to keep stake for at least a day.");
uint256 unit_reward = _stakes[_msgSender()] * _reward / 1e18;
uint256 units = (block.timestamp - _stake_ts[_msgSender()]) / _reward_period;
_stake_ts[_msgSender()] += units * _reward_period;
_mint(_msgSender(), unit_reward * units);
}
/**
* @dev put tokens into staking.
*
* CRI allows user to obtain reward by participating in staking. Users need
* to explicitly add their tokens for staking to be able to receive reward.
*
* - `amount` specifies amount of tokens to add stake for.
*
*/
function putStake(uint256 amount) public {
require(_balances[_msgSender()] >= amount, "CRI: Not enough balance");
require(_stakes[_msgSender()] == 0, "CRI: Must empty stake first");
_stakes[_msgSender()] = amount;
_stake_ts[_msgSender()] = block.timestamp;
_balances[_msgSender()] -= amount;
}
/**
* @dev retrieve tokens from staking.
*
* CRI allows user to obtain reward by participating in staking. Users need
* to explicitly add their tokens for staking to be able to receive reward.
*
*/
function retrieveStake() public {
require(_stakes[_msgSender()] >= 0, "CRI: Empty stake");
_balances[_msgSender()] += _stakes[_msgSender()];
_stakes[_msgSender()] = 0;
}
/**
* @dev view the amount of stake that the sender currently has.
*
*/
function viewStake() public
view
returns(uint256) {
return _stakes[_msgSender()];
}
/**
* @dev view the current reward period.
*
*/
function viewRewardPeriod() public
view
returns(uint256) {
return _reward_period;
}
/**
* @dev view the currenct reward per token.
*
*/
function viewReward() public
view
returns(uint256) {
return _reward;
}
}
Read Contract
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
decimals 0x313ce567 → uint8
name 0x06fdde03 → string
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
viewReward 0x34f2015d → uint256
viewRewardPeriod 0x986f7b15 → uint256
viewStake 0x04636349 → uint256
Write Contract 10 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address spender
uint256 amount
returns: bool
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
getReward 0x3d18b912
No parameters
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
mint 0xa0712d68
uint256 amount
putStake 0x2d53d984
uint256 amount
retrieveStake 0x3dda3da7
No parameters
setReward 0x293be456
uint256 reward
transfer 0xa9059cbb
address recipient
uint256 amount
returns: bool
transferFrom 0x23b872dd
address sender
address recipient
uint256 amount
returns: bool
Recent Transactions
No transactions found for this address