Address Contract Verified
Address
0xEB3611Ed793c7e3664cD5aaCAFd1167C8Fc49801
Balance
0 ETH
Nonce
1
Code Size
1213 bytes
Creator
0x2C7e9c9C...976b at tx 0xde64fd9b...896724
Indexed Transactions
0
Contract Bytecode
1213 bytes
0x608060405234801561000f575f80fd5b506004361061007a575f3560e01c8063a694fc3a11610058578063a694fc3a146100d5578063a87430ba146100e8578063b149e56814610123578063d67fd58214610144575f80fd5b80632e17de781461007e578063502c9bd51461009357806353cdcd2a146100c3575b5f80fd5b61009161008c3660046103ae565b61014c565b005b6100a66100a13660046103ae565b610233565b6040516001600160a01b0390911681526020015b60405180910390f35b5f546100a6906001600160a01b031681565b6100916100e33660046103ae565b61025b565b61010e6100f63660046103c5565b600160208190525f9182526040909120805491015482565b604080519283526020830191909152016100ba565b6101366101313660046103c5565b610350565b6040519081526020016100ba565b600254610136565b335f90815260016020526040902080548211156101a65760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b604482015260640160405180910390fd5b5f5460405163a9059cbb60e01b8152336004820152602481018490526001600160a01b039091169063a9059cbb906044016020604051808303815f875af11580156101f3573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061021791906103f2565b5081815f015f82825461022a9190610425565b90915550505050565b60028181548110610242575f80fd5b5f918252602090912001546001600160a01b0316905081565b335f9081526001602081905260408220908101549091036102b857600280546001810182555f919091527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180546001600160a01b031916331790555b5f546040516323b872dd60e01b8152336004820152306024820152604481018490526001600160a01b03909116906323b872dd906064016020604051808303815f875af115801561030b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061032f91906103f2565b5081815f015f828254610342919061043e565b909155505060019081015550565b6001600160a01b0381165f90815260016020818152604080842081518083019092528054808352930154918101919091529082906103989068138400eca364a0000090610451565b90506103a6816103e8610470565b949350505050565b5f602082840312156103be575f80fd5b5035919050565b5f602082840312156103d5575f80fd5b81356001600160a01b03811681146103eb575f80fd5b9392505050565b5f60208284031215610402575f80fd5b815180151581146103eb575f80fd5b634e487b7160e01b5f52601160045260245ffd5b8181038181111561043857610438610411565b92915050565b8082018082111561043857610438610411565b5f8261046b57634e487b7160e01b5f52601260045260245ffd5b500490565b80820281158282048414176104385761043861041156fea2646970667358221220fafa1cd7285762fc8361caf6fc02d23837573dbf32b77cd7c3a532b28988bbfb64736f6c63430008170033
Verified Source Code Full Match
Compiler: v0.8.23+commit.f704f362
EVM: shanghai
Optimization: Yes (200 runs)
MarsStake.sol 50 lines
pragma solidity ^0.8.22;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract MarsStake {
address public lmc;
struct User {
uint256 stake;
uint256 init;
}
mapping(address => User) public users;
address[] public userAddresses;
constructor() {
//test
// lmc = 0x5195b2709770180903b7aCB3841B081Ec7b6DfFf;
//main
lmc = 0x8983CF891867942d06AD6CEb9B9002de860E202d;
}
function getUserAddressesLength() external view returns (uint256) {
return userAddresses.length;
}
function stake(uint256 amount) external {
User storage user = users[msg.sender];
if (user.init == 0) {
userAddresses.push(msg.sender);
}
IERC20(lmc).transferFrom(msg.sender, address(this), amount);
user.stake += amount;
user.init = 1;
}
function unstake(uint256 amount) external {
User storage user = users[msg.sender];
require(user.stake >= amount, "Insufficient balance");
IERC20(lmc).transfer(msg.sender, amount);
user.stake -= amount;
}
function getPendingPoint(address addr) external view returns (uint256) {
User memory user = users[addr];
uint256 stakeUint = user.stake / 360 ether;
return stakeUint * 1000;
}
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @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 value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` 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 value) external returns (bool);
}
Read Contract
getPendingPoint 0xb149e568 → uint256
getUserAddressesLength 0xd67fd582 → uint256
lmc 0x53cdcd2a → address
userAddresses 0x502c9bd5 → address
users 0xa87430ba → uint256, uint256
Write Contract 2 functions
These functions modify contract state and require a wallet transaction to execute.
stake 0xa694fc3a
uint256 amount
unstake 0x2e17de78
uint256 amount
Recent Transactions
No transactions found for this address