Address Contract Partially Verified
Address
0xA62Fc0BA9Deeee9336511741c2Dfc4F5b00E128B
Balance
0 ETH
Nonce
1
Code Size
4490 bytes
Creator
0xDecD1344...EB0e at tx 0x537a57fd...45265b
Indexed Transactions
0
Contract Bytecode
4490 bytes
0x608060405234801561001057600080fd5b506004361061009e5760003560e01c806372cabf3d1161006657806372cabf3d146101595780639b9d02d514610189578063a694fc3a146101b9578063aaa76f22146101d5578063cf10568b146101f35761009e565b80630ae2bd49146100a3578063221e0bc6146100d357806326bd72a6146101035780632e17de78146101335780634641257d1461014f575b600080fd5b6100bd60048036038101906100b89190610ad6565b610211565b6040516100ca9190610f28565b60405180910390f35b6100ed60048036038101906100e89190610ad6565b610267565b6040516100fa9190610f28565b60405180910390f35b61011d60048036038101906101189190610ad6565b6102b0565b60405161012a9190610f28565b60405180910390f35b61014d60048036038101906101489190610b28565b6102f9565b005b61015761050f565b005b610173600480360381019061016e9190610ad6565b610694565b6040516101809190610f28565b60405180910390f35b6101a3600480360381019061019e9190610ad6565b6106fb565b6040516101b09190610f28565b60405180910390f35b6101d360048036038101906101ce9190610b28565b610744565b005b6101dd610a54565b6040516101ea9190610da4565b60405180910390f35b6101fb610a78565b6040516102089190610f28565b60405180910390f35b60006103e8600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546102609190610faa565b9050919050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b80600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561037b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161037290610e68565b60405180910390fd5b61038361050f565b80600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546103d29190611035565b9250508190555060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33846040518363ffffffff1660e01b8152600401610437929190610e1f565b602060405180830381600087803b15801561045157600080fd5b505af1158015610465573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104899190610aff565b905060011515811515146104d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104c990610ea8565b60405180910390fd5b7fe6dabef69dffaa9786923d67e8ad17248d542d64ec382c9ed9e789e672a6eea53383604051610503929190610e1f565b60405180910390a15050565b600061051a33610694565b90506000811015610560576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161055790610ec8565b60405180910390fd5b42600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546105ef9190610f54565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555080600160008282546106449190610f54565b9250508190555060006001541015610691576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161068890610e88565b60405180910390fd5b50565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054426106e19190611035565b6106ea83610211565b6106f49190610fdb565b9050919050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60008111610787576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161077e90610e48565b60405180910390fd5b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e33306040518363ffffffff1660e01b81526004016107e5929190610dbf565b60206040518083038186803b1580156107fd57600080fd5b505afa158015610811573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108359190610b51565b90506000811161087a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161087190610ee8565b60405180910390fd5b818110156108bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108b490610f08565b60405180910390fd5b6108c561050f565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330866040518463ffffffff1660e01b815260040161092593929190610de8565b602060405180830381600087803b15801561093f57600080fd5b505af1158015610953573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109779190610aff565b905060011515811515146109c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109b790610ea8565b60405180910390fd5b82600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610a0f9190610f54565b925050819055507f3652eddfe31e4d0c62e545f8ae4c0605f1fd1b157b52a3e2db39935ffc2a9a303384604051610a47929190610e1f565b60405180910390a1505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600154905090565b600081359050610a918161110f565b92915050565b600081519050610aa681611126565b92915050565b600081359050610abb8161113d565b92915050565b600081519050610ad08161113d565b92915050565b600060208284031215610ae857600080fd5b6000610af684828501610a82565b91505092915050565b600060208284031215610b1157600080fd5b6000610b1f84828501610a97565b91505092915050565b600060208284031215610b3a57600080fd5b6000610b4884828501610aac565b91505092915050565b600060208284031215610b6357600080fd5b6000610b7184828501610ac1565b91505092915050565b610b8381611069565b82525050565b6000610b96601f83610f43565b91507f7374616b6520616d6f756e74206d75737420626967676572207468656e2030006000830152602082019050919050565b6000610bd6601283610f43565b91507f6e6f7420656e6f7567682062616c616e636500000000000000000000000000006000830152602082019050919050565b6000610c16601983610f43565b91507f746f74616c5f637265646974206f766572666c6f7720657272000000000000006000830152602082019050919050565b6000610c56600e83610f43565b91507f7472616e73666572206572726f720000000000000000000000000000000000006000830152602082019050919050565b6000610c96602b83610f43565b91507f6372656469745f72657761726420736d616c6c6572207468656e20302065727260008301527f20696e20686172766573740000000000000000000000000000000000000000006020830152604082019050919050565b6000610cfc602483610f43565b91507f706c6561736520617070726f766520746f6b656e73206265666f72652073746160008301527f6b696e67000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610d62601a83610f43565b91507f706c6561736520617070726f7665206d6f726520746f6b656e730000000000006000830152602082019050919050565b610d9e816110a7565b82525050565b6000602082019050610db96000830184610b7a565b92915050565b6000604082019050610dd46000830185610b7a565b610de16020830184610b7a565b9392505050565b6000606082019050610dfd6000830186610b7a565b610e0a6020830185610b7a565b610e176040830184610d95565b949350505050565b6000604082019050610e346000830185610b7a565b610e416020830184610d95565b9392505050565b60006020820190508181036000830152610e6181610b89565b9050919050565b60006020820190508181036000830152610e8181610bc9565b9050919050565b60006020820190508181036000830152610ea181610c09565b9050919050565b60006020820190508181036000830152610ec181610c49565b9050919050565b60006020820190508181036000830152610ee181610c89565b9050919050565b60006020820190508181036000830152610f0181610cef565b9050919050565b60006020820190508181036000830152610f2181610d55565b9050919050565b6000602082019050610f3d6000830184610d95565b92915050565b600082825260208201905092915050565b6000610f5f826110a7565b9150610f6a836110a7565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610f9f57610f9e6110b1565b5b828201905092915050565b6000610fb5826110a7565b9150610fc0836110a7565b925082610fd057610fcf6110e0565b5b828204905092915050565b6000610fe6826110a7565b9150610ff1836110a7565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561102a576110296110b1565b5b828202905092915050565b6000611040826110a7565b915061104b836110a7565b92508282101561105e5761105d6110b1565b5b828203905092915050565b600061107482611087565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b61111881611069565b811461112357600080fd5b50565b61112f8161107b565b811461113a57600080fd5b50565b611146816110a7565b811461115157600080fd5b5056fea2646970667358221220e7ae2dff6e9a754d6d0cfdedc697fa6e6b0fa5ae0254d9662e192b80e12f7adb64736f6c63430008000033
Verified Source Code Partial Match
Compiler: v0.8.0+commit.c7dfd78e
EVM: istanbul
Optimization: No
MSN_STAKE.sol 171 lines
// File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v4.9/contracts/token/ERC20/IERC20.sol
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @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);
/**
* @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 `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, 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 `from` to `to` 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 from, address to, uint256 amount) external returns (bool);
}
// File: contracts/MSN_STAKE.sol
pragma solidity ^0.8.0;
contract MSN_STAKE {
address public msn_contract_address;
constructor(address _msn_contract_addr) {
msn_contract_address = _msn_contract_addr;
}
uint256 private total_credit;
function get_total_credit() external view returns (uint256) {
return total_credit;
}
mapping(address => uint256) private credit_map;
function get_credit(address addr) external view returns (uint256) {
return credit_map[addr];
}
mapping(address => uint256) private stake_token_map;
function get_stake_token(address addr) external view returns (uint256) {
return stake_token_map[addr];
}
mapping(address => uint256) private stake_last_time_map;
function get_stake_last_time(address addr) external view returns (uint256) {
return stake_last_time_map[addr];
}
function cal_credit_reward(address addr) public view returns (uint256) {
return get_credit_reward_speed(addr) * (block.timestamp - stake_last_time_map[addr]);
}
function get_credit_reward_speed(address addr) public view returns (uint256) {
return stake_token_map[addr] / 1000;
}
function harvest() public {
uint256 credit_reward = cal_credit_reward(msg.sender);
require(credit_reward >= 0, "credit_reward smaller then 0 err in harvest");
stake_last_time_map[msg.sender] = block.timestamp;
credit_map[msg.sender] = credit_map[msg.sender] + credit_reward;
total_credit += credit_reward;
require(total_credit >= 0, "total_credit overflow err");
}
event stake_EVENT(address trigger_user_addr, uint256 amount);
function stake(uint256 amount) external {
require(amount > 0, "stake amount must bigger then 0");
uint256 allowance = IERC20(msn_contract_address).allowance(msg.sender, address(this));
require(allowance > 0, "please approve tokens before staking");
require(allowance >= amount, "please approve more tokens");
harvest();
bool t_result = IERC20(msn_contract_address).transferFrom(msg.sender, address(this), amount);
require(t_result == true, "transfer error");
stake_token_map[msg.sender] += amount;
emit stake_EVENT(msg.sender, amount);
}
event unstake_EVENT(address trigger_user_addr, uint256 amount);
function unstake(uint256 amount) external {
require(stake_token_map[msg.sender] >= amount, "not enough balance");
harvest();
stake_token_map[msg.sender] -= amount;
//transfer
bool t_result = IERC20(msn_contract_address).transfer(msg.sender, amount);
require(t_result == true, "transfer error");
emit unstake_EVENT(msg.sender, amount);
}
}
Read Contract
cal_credit_reward 0x72cabf3d → uint256
get_credit 0x221e0bc6 → uint256
get_credit_reward_speed 0x0ae2bd49 → uint256
get_stake_last_time 0x9b9d02d5 → uint256
get_stake_token 0x26bd72a6 → uint256
get_total_credit 0xcf10568b → uint256
msn_contract_address 0xaaa76f22 → address
Write Contract 3 functions
These functions modify contract state and require a wallet transaction to execute.
harvest 0x4641257d
No parameters
stake 0xa694fc3a
uint256 amount
unstake 0x2e17de78
uint256 amount
Recent Transactions
No transactions found for this address