Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0xEc754f469b6C70a6DB4B5C26C8bA51Da94c74757
Balance 0 ETH
Nonce 1
Code Size 7757 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

7757 bytes
0x608060405234801561000f575f80fd5b50600436106101a1575f3560e01c8063624601b6116100f357806395d89b4111610093578063ca3c782c1161006e578063ca3c782c14610458578063dd62ed3e1461046b578063f2fde38b146104a3578063fb7265ff146104b6575f80fd5b806395d89b411461042a578063a9059cbb14610432578063bce1b52014610445575f80fd5b806372706a8c116100ce57806372706a8c146103bb5780637b0472f0146103e657806385209ee0146103f95780638da5cb5b1461041a575f80fd5b8063624601b61461036c57806370a082311461038b578063715018a6146103b3575f80fd5b8063313ce5671161015e578063522f681511610139578063522f6815146102685780635733c7861461027b578063584b62a11461028e5780635aad6cf0146102e7575f80fd5b8063313ce567146102335780633ccdbb28146102425780634268121e14610255575f80fd5b806306fdde03146101a5578063095ea7b3146101c357806318160ddd146101e65780631852e8d9146101f857806323b872dd1461020b5780632e17de781461021e575b5f80fd5b6101ad6104c9565b6040516101ba9190611a66565b60405180910390f35b6101d66101d1366004611acc565b610559565b60405190151581526020016101ba565b6003545b6040519081526020016101ba565b6101ea610206366004611acc565b610572565b6101d6610219366004611af4565b610611565b61023161022c366004611b2d565b610634565b005b604051601281526020016101ba565b610231610250366004611b44565b61086b565b610231610263366004611acc565b6109fe565b610231610276366004611acc565b610bbe565b610231610289366004611b7d565b610cf2565b6102ca61029c366004611acc565b600760209081525f928352604080842090915290825290208054600182015460029092015490919060ff1683565b6040805193845260208401929092521515908201526060016101ba565b6103356102f5366004611b2d565b600660208190525f918252604090912080546001820154600283015460038401546004850154600586015495909601549395929491939092919060ff1687565b604080519788526020880196909652948601939093526060850191909152608084015260a0830152151560c082015260e0016101ba565b6101ea61037a366004611b7d565b60086020525f908152604090205481565b6101ea610399366004611b7d565b6001600160a01b03165f9081526001602052604090205490565b610231610d1c565b6009546103ce906001600160a01b031681565b6040516001600160a01b0390911681526020016101ba565b6102316103f4366004611b9d565b610d2f565b60095461040d90600160a01b900460ff1681565b6040516101ba9190611bd1565b5f546001600160a01b03166103ce565b6101ad611087565b6101d6610440366004611acc565b611096565b610231610453366004611b2d565b6110a3565b610231610466366004611c04565b611320565b6101ea610479366004611c55565b6001600160a01b039182165f90815260026020908152604080832093909416825291909152205490565b6102316104b1366004611b7d565b611577565b6102316104c4366004611b2d565b6115f0565b6060600480546104d890611c86565b80601f016020809104026020016040519081016040528092919081815260200182805461050490611c86565b801561054f5780601f106105265761010080835404028352916020019161054f565b820191905f5260205f20905b81548152906001019060200180831161053257829003601f168201915b5050505050905090565b5f33610566818585611675565b60019150505b92915050565b6001600160a01b0382165f90815260076020908152604080832084845290915281206001015481906105a49042611cd2565b5f848152600660209081526040808320546001600160a01b038916845260078352818420888552909252909120549192506301e13380918391612710916105eb9190611ce5565b6105f59190611cfc565b6105ff9190611ce5565b6106099190611cfc565b949350505050565b5f3361061e858285611682565b6106298585856116fd565b506001949350505050565b600180600954600160a01b900460ff16600181111561065557610655611bbd565b1461067b5760405162461bcd60e51b815260040161067290611d1b565b60405180910390fd5b335f9081526007602090815260408083208584529091529020600281015460ff166106b85760405162461bcd60e51b815260040161067290611d60565b5f8381526006602052604090206106d28462015180611ce5565b82600101546106e19190611d8f565b4210156107305760405162461bcd60e51b815260206004820152601a60248201527f4c6f636b20706572696f6420686173206e6f74207061737365640000000000006044820152606401610672565b81545f61073d3387610572565b335f90815260086020526040812080549293508392909190610760908490611d8f565b909155505060095460405163a9059cbb60e01b8152336004820152602481018490526001600160a01b039091169063a9059cbb906044016020604051808303815f875af11580156107b3573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107d79190611da2565b5060028401805460ff191690556004830180548391905f906107fa908490611cd2565b925050819055506001836005015f8282546108159190611cd2565b909155506108259050338361175a565b6040805183815260208101839052879133917f204fccf0d92ed8d48f204adb39b2e81e92bad0dedb93f5716ca9478cfb57de0091015b60405180910390a3505050505050565b610873611792565b6001600160a01b0383166108bc5760405162461bcd60e51b815260206004820152601060248201526f496e76616c696420416464726573732160801b6044820152606401610672565b5f82116108fd5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c696420416d6f756e742160881b6044820152606401610672565b6001600160a01b0381166109445760405162461bcd60e51b815260206004820152600e60248201526d496e76616c696420546f6b656e2160901b6044820152606401610672565b60405163a9059cbb60e01b81526001600160a01b0384811660048301526024820184905282169063a9059cbb906044016020604051808303815f875af1158015610990573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109b49190611da2565b6109f95760405162461bcd60e51b8152602060048201526016602482015275556e7375636365737366756c205472616e736665722160501b6044820152606401610672565b505050565b610a06611792565b6001600160a01b0382165f9081526007602090815260408083208484529091529020600281015460ff16610a4c5760405162461bcd60e51b815260040161067290611d60565b5f82815260066020526040812082549091610a6a8562015180611ce5565b8460010154610a799190611d8f565b4210610abb57610a893386610572565b6001600160a01b0387165f90815260086020526040812080549293508392909190610ab5908490611d8f565b90915550505b60095460405163a9059cbb60e01b8152336004820152602481018490526001600160a01b039091169063a9059cbb906044016020604051808303815f875af1158015610b09573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b2d9190611da2565b5060028401805460ff191690556004830180548391905f90610b50908490611cd2565b925050819055506001836005015f828254610b6b9190611cd2565b90915550610b7b9050868361175a565b604080518381526020810183905286916001600160a01b038916917f204fccf0d92ed8d48f204adb39b2e81e92bad0dedb93f5716ca9478cfb57de00910161085b565b610bc6611792565b6001600160a01b038216610c0f5760405162461bcd60e51b815260206004820152601060248201526f496e76616c696420416464726573732160801b6044820152606401610672565b5f81118015610c1e5750804710155b610c5c5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c696420416d6f756e742160881b6044820152606401610672565b5f826001600160a01b0316826040515f6040518083038185875af1925050503d805f8114610ca5576040519150601f19603f3d011682016040523d82523d5f602084013e610caa565b606091505b50509050806109f95760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321022ba3432b960611b6044820152606401610672565b610cfa611792565b600980546001600160a01b0319166001600160a01b0392909216919091179055565b610d24611792565b610d2d5f6117eb565b565b600180600954600160a01b900460ff166001811115610d5057610d50611bbd565b14610d6d5760405162461bcd60e51b815260040161067290611d1b565b5f838152600660208181526040808420338552600783528185208886529092529092209082015460ff16610de35760405162461bcd60e51b815260206004820152601a60248201527f5374616b696e6720706f6f6c206973206e6f74206163746976650000000000006044820152606401610672565b6001820154335f908152600760209081526040808320898452909152902054610e0c9086611d8f565b1015610e645760405162461bcd60e51b815260206004820152602160248201527f416d6f756e74206973206c657373207468616e206d696e696d756d207374616b6044820152606560f81b6064820152608401610672565b6002820154335f908152600760209081526040808320898452909152902054610e8d9086611d8f565b1115610edb5760405162461bcd60e51b815260206004820152601c60248201527f416d6f756e742065786365656473206d6178696d756d207374616b65000000006044820152606401610672565b8160030154848360040154610ef09190611d8f565b1115610f0e5760405162461bcd60e51b815260040161067290611dbd565b600281015460ff1615610f795760405162461bcd60e51b815260206004820152602d60248201527f5573657220616c72656164792068617320616e20616374697665207374616b6560448201526c081a5b881d1a1a5cc81c1bdbdb609a1b6064820152608401610672565b6009546040516323b872dd60e01b8152336004820152306024820152604481018690526001600160a01b03909116906323b872dd906064016020604051808303815f875af1158015610fcd573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ff19190611da2565b508381554260018083019190915560028201805460ff191690911790556004820180548591905f90611024908490611d8f565b9091555050600582018054905f61103a83611dff565b9190505550611049338561183a565b604051848152859033907f1449c6dd7851abc30abf37f57715f492010519147cc2652fbc38202c18a6ee909060200160405180910390a35050505050565b6060600580546104d890611c86565b5f336105668185856116fd565b600180600954600160a01b900460ff1660018111156110c4576110c4611bbd565b146110e15760405162461bcd60e51b815260040161067290611d1b565b335f9081526007602090815260408083208584529091529020600281015460ff1661111e5760405162461bcd60e51b815260040161067290611d60565b5f8381526006602052604090206111388462015180611ce5565b82600101546111479190611d8f565b4210156111965760405162461bcd60e51b815260206004820152601a60248201527f4c6f636b20706572696f6420686173206e6f74207061737365640000000000006044820152606401610672565b81545f6111a33387610572565b90505f6111b08284611d8f565b905083600101548110156112185760405162461bcd60e51b815260206004820152602960248201527f52657374616b6520616d6f756e74206973206c657373207468616e206d696e696044820152686d756d207374616b6560b81b6064820152608401610672565b83600201548111156112785760405162461bcd60e51b8152602060048201526024808201527f52657374616b6520616d6f756e742065786365656473206d6178696d756d207360448201526374616b6560e01b6064820152608401610672565b836003015482856004015461128d9190611d8f565b11156112ab5760405162461bcd60e51b815260040161067290611dbd565b8085554260018601556004840180548391905f906112ca908490611d8f565b909155506112da9050338361183a565b6040805184815260208101849052889133917f63acdca311ce77b458c1dde8cdea3e282508af05da37a4f52a915b7784c37c48910160405180910390a350505050505050565b611328611792565b5f8511801561133957506127108511155b6113855760405162461bcd60e51b815260206004820152601d60248201527f415052206d757374206265206265747765656e203120616e64203130300000006044820152606401610672565b5f84116113e05760405162461bcd60e51b8152602060048201526024808201527f4d696e696d756d207374616b65206d75737420626520677265617465722074686044820152630616e20360e41b6064820152608401610672565b838310156114565760405162461bcd60e51b815260206004820152603c60248201527f4d6178696d756d207374616b65206d757374206265206772656174657220746860448201527f616e206f7220657175616c20746f206d696e696d756d207374616b65000000006064820152608401610672565b828210156114de5760405162461bcd60e51b815260206004820152604960248201527f546f74616c206d6178696d756d207374616b6520616d6f756e74206d7573742060448201527f62652067726561746572207468616e206f7220657175616c20746f206d6178696064820152686d756d207374616b6560b81b608482015260a401610672565b5f86815260066020818152604092839020888155600181018890556002810187905560038101869055918201805460ff191685151590811790915583518a8152918201899052928101879052606081018690526080810185905260a0810192909252907f497768b3d65a26bbe0117804b6c1f7dbfd9bfd4e4a4d9af2aec5f9f64b2681019060c00160405180910390a150505050505050565b61157f611792565b6001600160a01b0381166115e45760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610672565b6115ed816117eb565b50565b6115f8611792565b600281106116395760405162461bcd60e51b815260206004820152600e60248201526d496e76616c69642053746174652160901b6044820152606401610672565b80600181111561164b5761164b611bbd565b6009805460ff60a01b1916600160a01b83600181111561166d5761166d611bbd565b021790555050565b6109f9838383600161186e565b6001600160a01b038381165f908152600260209081526040808320938616835292905220545f1981146116f757818110156116e957604051637dc7a0d960e11b81526001600160a01b03841660048201526024810182905260448101839052606401610672565b6116f784848484035f61186e565b50505050565b6001600160a01b03831661172657604051634b637e8f60e11b81525f6004820152602401610672565b6001600160a01b03821661174f5760405163ec442f0560e01b81525f6004820152602401610672565b6109f9838383611940565b6001600160a01b03821661178357604051634b637e8f60e11b81525f6004820152602401610672565b61178e825f83611940565b5050565b5f546001600160a01b03163314610d2d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610672565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b0382166118635760405163ec442f0560e01b81525f6004820152602401610672565b61178e5f8383611940565b6001600160a01b0384166118975760405163e602df0560e01b81525f6004820152602401610672565b6001600160a01b0383166118c057604051634a1406b160e11b81525f6004820152602401610672565b6001600160a01b038085165f90815260026020908152604080832093871683529290522082905580156116f757826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161193291815260200190565b60405180910390a350505050565b6001600160a01b03831661196a578060035f82825461195f9190611d8f565b909155506119da9050565b6001600160a01b0383165f90815260016020526040902054818110156119bc5760405163391434e360e21b81526001600160a01b03851660048201526024810182905260448101839052606401610672565b6001600160a01b0384165f9081526001602052604090209082900390555b6001600160a01b0382166119f657600380548290039055611a14565b6001600160a01b0382165f9081526001602052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051611a5991815260200190565b60405180910390a3505050565b5f6020808352835180828501525f5b81811015611a9157858101830151858201604001528201611a75565b505f604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b0381168114611ac7575f80fd5b919050565b5f8060408385031215611add575f80fd5b611ae683611ab1565b946020939093013593505050565b5f805f60608486031215611b06575f80fd5b611b0f84611ab1565b9250611b1d60208501611ab1565b9150604084013590509250925092565b5f60208284031215611b3d575f80fd5b5035919050565b5f805f60608486031215611b56575f80fd5b611b5f84611ab1565b925060208401359150611b7460408501611ab1565b90509250925092565b5f60208284031215611b8d575f80fd5b611b9682611ab1565b9392505050565b5f8060408385031215611bae575f80fd5b50508035926020909101359150565b634e487b7160e01b5f52602160045260245ffd5b6020810160028310611bf157634e487b7160e01b5f52602160045260245ffd5b91905290565b80151581146115ed575f80fd5b5f805f805f8060c08789031215611c19575f80fd5b863595506020870135945060408701359350606087013592506080870135915060a0870135611c4781611bf7565b809150509295509295509295565b5f8060408385031215611c66575f80fd5b611c6f83611ab1565b9150611c7d60208401611ab1565b90509250929050565b600181811c90821680611c9a57607f821691505b602082108103611cb857634e487b7160e01b5f52602260045260245ffd5b50919050565b634e487b7160e01b5f52601160045260245ffd5b8181038181111561056c5761056c611cbe565b808202811582820484141761056c5761056c611cbe565b5f82611d1657634e487b7160e01b5f52601260045260245ffd5b500490565b60208082526025908201527f436f6e7472616374206973206e6f7420696e2074686520726571756972656420604082015264737461746560d81b606082015260800190565b602080825260159082015274139bc81858dd1a5d99481cdd185ad948199bdd5b99605a1b604082015260600190565b8082018082111561056c5761056c611cbe565b5f60208284031215611db2575f80fd5b8151611b9681611bf7565b60208082526022908201527f4578636565647320746f74616c206d6178696d756d207374616b6520616d6f756040820152611b9d60f21b606082015260800190565b5f60018201611e1057611e10611cbe565b506001019056fea2646970667358221220cbf9715f334991d3b8316512d9b2bdb409ab5f70d96d682737399fc6ee0e7a2764736f6c63430008140033

Verified Source Code Partial Match

Compiler: v0.8.20+commit.a1b79de6 EVM: shanghai Optimization: Yes (200 runs)
EMRLDStaking.sol 1034 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

/// @title $EMRLD Staking
/// @author Andre Costa @ MyWeb3Startup.com


// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

/**
 * @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;
    }
}

// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
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);
}

/**
 * @dev Interface for the optional metadata functions from the ERC-20 standard.
 */
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);
}

/**
 * @dev Standard ERC-20 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
 */
interface IERC20Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC20InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC20InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     * @param allowance Amount of tokens a `spender` is allowed to operate with.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC20InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `spender` to be approved. Used in approvals.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC20InvalidSpender(address spender);
}

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * The default value of {decimals} is 18. To change this, you should override
 * this function so it returns a different value.
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC-20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the ERC may not emit
 * these events, as it isn't required by the specification.
 */
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
    mapping(address account => uint256) private _balances;

    mapping(address account => mapping(address spender => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual 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 default value returned by this function, unless
     * it's 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 returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `value`.
     */
    function transfer(address to, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, value);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, value);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the ERC. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `value`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `value`.
     */
    function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, value);
        _transfer(from, to, value);
        return true;
    }

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _transfer(address from, address to, uint256 value) internal virtual {
        if (from == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        if (to == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(from, to, value);
    }

    /**
     * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
     * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
     * this function.
     *
     * Emits a {Transfer} event.
     */
    function _update(address from, address to, uint256 value) internal virtual {
        if (from == address(0)) {
            // Overflow check required: The rest of the code assumes that totalSupply never overflows
            _totalSupply += value;
        } else {
            uint256 fromBalance = _balances[from];
            if (fromBalance < value) {
                revert ERC20InsufficientBalance(from, fromBalance, value);
            }
            unchecked {
                // Overflow not possible: value <= fromBalance <= totalSupply.
                _balances[from] = fromBalance - value;
            }
        }

        if (to == address(0)) {
            unchecked {
                // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
                _totalSupply -= value;
            }
        } else {
            unchecked {
                // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
                _balances[to] += value;
            }
        }

        emit Transfer(from, to, value);
    }

    /**
     * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
     * Relies on the `_update` mechanism
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _mint(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(address(0), account, value);
    }

    /**
     * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
     * Relies on the `_update` mechanism.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead
     */
    function _burn(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        _update(account, address(0), value);
    }

    /**
     * @dev Sets `value` 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.
     *
     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
     */
    function _approve(address owner, address spender, uint256 value) internal {
        _approve(owner, spender, value, true);
    }

    /**
     * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
     *
     * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
     * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
     * `Approval` event during `transferFrom` operations.
     *
     * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
     * true using the following override:
     * ```
     * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
     *     super._approve(owner, spender, value, true);
     * }
     * ```
     *
     * Requirements are the same as {_approve}.
     */
    function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
        if (owner == address(0)) {
            revert ERC20InvalidApprover(address(0));
        }
        if (spender == address(0)) {
            revert ERC20InvalidSpender(address(0));
        }
        _allowances[owner][spender] = value;
        if (emitEvent) {
            emit Approval(owner, spender, value);
        }
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `value`.
     *
     * Does not update the allowance value in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Does not emit an {Approval} event.
     */
    function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            if (currentAllowance < value) {
                revert ERC20InsufficientAllowance(spender, currentAllowance, value);
            }
            unchecked {
                _approve(owner, spender, currentAllowance - value, false);
            }
        }
    }
}

// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;

    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);
}

contract EMRLDStaking is Ownable, ERC20 {

    /**
     * @dev Struct to represent a staking pool with specific parameters.
     */
    struct StakingPool {
        uint256 apr; // Annual Percentage Rate for the staking pool.
        uint256 minStake; // Minimum staking amount allowed.
        uint256 maxStake; // Maximum staking amount allowed.
        uint256 totalMaxStakeAmount; // Total maximum amount that can be staked in this pool.
        uint256 totalStaked; // Total amount currently staked in this pool.
        uint256 totalStakers; // Total number of stakers in this pool.
        bool active; // Boolean to indicate if the pool is active.
    }
    mapping(uint256 => StakingPool) public stakingPools; // Mapping of staking pool IDs to their respective pools.

    /**
     * @dev Struct to represent a stake made by a user.
     */
    struct Stake {
        uint256 totalStaked;  // Total amount of ETH staked by the user.
        uint256 stakeTimestamp;  // Last timestamp the user's staking data was updated.
        bool isActive; // Boolean to indicate if the stake is currently active.
    }
    mapping(address => mapping(uint256 => Stake)) public stakes;  // Maps user addresses to their staking information.

    mapping(address => uint256) public tokensClaimed; // Mapping of user addresses to the total amount of tokens claimed.

    IERC20Metadata public EMRLD;  // ERC20 token for EMRLD.

    /**
     * @dev Enum to represent the state of the contract.
     */
    enum ContractState { OFF, OPEN }  // States of contract: OFF for not accepting stakes, OPEN for accepting stakes.
    ContractState public contractState = ContractState.OPEN;  // Initial state of the contract.

    /**
     * @dev Event emitted when a new staking pool is created.
     * @param lock The lock period for the staking pool.
     * @param apr The APR for the staking pool.
     * @param minStake The minimum stake amount for the staking pool.
     * @param maxStake The maximum stake amount for the staking pool.
     * @param totalMaxStakeAmount The total maximum stake amount for the staking pool.
     * @param active Whether the staking pool is active.
     */
    event StakingPoolCreated(uint256 lock, uint256 apr, uint256 minStake, uint256 maxStake, uint256 totalMaxStakeAmount, bool active);

    /**
     * @dev Event emitted when a user stakes tokens.
     * @param user The address of the user.
     * @param lock The ID of the staking pool.
     * @param amount The amount of tokens staked.
     */
    event Staked(address indexed user, uint256 indexed lock, uint256 amount);

    /**
     * @dev Event emitted when a user unstakes tokens.
     * @param user The address of the user.
     * @param lock The ID of the staking pool.
     * @param amount The amount of tokens unstaked.
     * @param rewards The amount of rewards earned.
     */
    event Unstaked(address indexed user, uint256 indexed lock, uint256 amount, uint256 rewards);

    /**
     * @dev Event emitted when a user restakes tokens.
     * @param user The address of the user.
     * @param lock The ID of the staking pool.
     * @param amount The amount of tokens restaked.
     * @param rewards The amount of rewards earned.
     */
    event Restaked(address indexed user, uint256 indexed lock, uint256 amount, uint256 rewards);

    /**
     * @dev Constructor to set the name and symbol for the staked tokens.
     */
    constructor() ERC20("xEMRLD", "xEMRLD") {
        EMRLD = IERC20Metadata(0xeBB1AFb0A4ddC9b1f84D9Aa72FF956cD1c1Eb4be);
    }

    /**
     * @dev Modifier to check the contract's current state before proceeding.
     * @param requiredState The state that the contract must be in.
     */
    modifier isContractState(ContractState requiredState) {
        require(contractState == requiredState, "Contract is not in the required state");
        _;
    }

    /**
     * @dev Function to stake tokens in a specific pool.
     * @param lock The ID of the staking pool.
     * @param amount The amount of tokens to stake.
     */
    function stake(uint256 lock, uint256 amount) external isContractState(ContractState.OPEN) {
        StakingPool storage pool = stakingPools[lock];
        Stake storage userStake = stakes[msg.sender][lock];

        require(pool.active, "Staking pool is not active");
        require(amount + stakes[msg.sender][lock].totalStaked >= pool.minStake, "Amount is less than minimum stake");
        require(amount + stakes[msg.sender][lock].totalStaked <= pool.maxStake, "Amount exceeds maximum stake");
        require(pool.totalStaked + amount <= pool.totalMaxStakeAmount, "Exceeds total maximum stake amount");
        require(!userStake.isActive, "User already has an active stake in this pool");

        EMRLD.transferFrom(msg.sender, address(this), amount);

        userStake.totalStaked = amount;
        userStake.stakeTimestamp = block.timestamp;
        userStake.isActive = true;

        pool.totalStaked += amount;
        pool.totalStakers++;

        _mint(msg.sender, amount);

        emit Staked(msg.sender, lock, amount);
    }

    /**
     * @dev Function to unstake tokens from a specific pool.
     * @param lock The ID of the staking pool.
     */
    function unstake(uint256 lock) external isContractState(ContractState.OPEN) {
        Stake storage userStake = stakes[msg.sender][lock];
        require(userStake.isActive, "No active stake found");
        
        StakingPool storage pool = stakingPools[lock];
        require(block.timestamp >= userStake.stakeTimestamp + lock * 86400, "Lock period has not passed");

        uint256 amountStaked = userStake.totalStaked;
        uint256 rewards = calculateReward(msg.sender, lock);
        tokensClaimed[msg.sender] += rewards;

        // Transfer the staked amount and rewards back to the user
        // EMRLD.transfer(msg.sender, rewards);
        EMRLD.transfer(msg.sender, amountStaked);

        // Update the user's stake and the pool's totals
        userStake.isActive = false;
        pool.totalStaked -= amountStaked;
        pool.totalStakers -= 1;

        _burn(msg.sender, amountStaked);

        emit Unstaked(msg.sender, lock, amountStaked, rewards);
    }

    /**
     * @dev Function to restake tokens and rewards in a specific pool.
     * @param lock The ID of the staking pool.
     */
    function restake(uint256 lock) external isContractState(ContractState.OPEN) {
        Stake storage userStake = stakes[msg.sender][lock];
        require(userStake.isActive, "No active stake found");

        StakingPool storage pool = stakingPools[lock];
        require(block.timestamp >= userStake.stakeTimestamp + lock * 86400, "Lock period has not passed");

        uint256 amountStaked = userStake.totalStaked;
        uint256 rewards = calculateReward(msg.sender, lock);

        // Ensure the total amount to be restaked doesn't exceed pool's maximum limits
        uint256 totalToRestake = amountStaked + rewards;
        require(totalToRestake >= pool.minStake, "Restake amount is less than minimum stake");
        require(totalToRestake <= pool.maxStake, "Restake amount exceeds maximum stake");
        require(pool.totalStaked + rewards <= pool.totalMaxStakeAmount, "Exceeds total maximum stake amount");

        // Update user's stake
        userStake.totalStaked = totalToRestake;
        userStake.stakeTimestamp = block.timestamp;

        // Update the pool's total staked amount (adding only rewards, as the initial staked amount is already included)
        pool.totalStaked += rewards;

        _mint(msg.sender, rewards);

        emit Restaked(msg.sender, lock, amountStaked, rewards);
    }

    /**
     * @dev Emergency function for the owner to unstake tokens for a user.
     * @param user The address of the user.
     * @param lock The ID of the staking pool.
     */
    function emergencyUnstake(address user, uint256 lock) external onlyOwner {
        Stake storage userStake = stakes[user][lock];
        require(userStake.isActive, "No active stake found");

        StakingPool storage pool = stakingPools[lock];

        uint256 amountStaked = userStake.totalStaked;

        uint256 rewards;
        if (block.timestamp >= userStake.stakeTimestamp + lock * 86400) {
            rewards = calculateReward(msg.sender, lock);
            tokensClaimed[user] += rewards;
        }

        // Transfer the staked amount and rewards back to the user
        // EMRLD.transfer(msg.sender, rewards);
        EMRLD.transfer(msg.sender, amountStaked);

        // Update the user's stake and the pool's totals
        userStake.isActive = false;
        pool.totalStaked -= amountStaked;
        pool.totalStakers -= 1;

        _burn(user, amountStaked);

        emit Unstaked(user, lock, amountStaked, rewards);
    }

    /**
     * @dev Calculates the total rewards earned by a staker based on the staked amounts and time elapsed.
     * @param staker The address of the staker.
     * @param lock The ID of the staking pool.
     * @return The total rewards earned.
     */
    function calculateReward(address staker, uint256 lock) public view returns (uint256) {
        uint256 timeStaked = block.timestamp - stakes[staker][lock].stakeTimestamp;
        return (((stakes[staker][lock].totalStaked * stakingPools[lock].apr) / 10000) * timeStaked) / (365 days);
    }

    ///
    /// SETTERS
    ///

    /**
     * @dev Function to set up a staking pool.
     * @param lock The lock period for the staking pool.
     * @param apr The APR for the staking pool.
     * @param minStake The minimum stake amount.
     * @param maxStake The maximum stake amount.
     * @param totalMaxStakeAmount The total maximum amount that can be staked in the pool.
     * @param active Boolean indicating if the pool is active.
     */
    function setStakingPool(
        uint256 lock,
        uint256 apr,
        uint256 minStake,
        uint256 maxStake,
        uint256 totalMaxStakeAmount,
        bool active
    ) public onlyOwner {
        require(apr > 0 && apr <= 10000, "APR must be between 1 and 100");
        require(minStake > 0, "Minimum stake must be greater than 0");
        require(maxStake >= minStake, "Maximum stake must be greater than or equal to minimum stake");
        require(totalMaxStakeAmount >= maxStake, "Total maximum stake amount must be greater than or equal to maximum stake");

        StakingPool storage pool = stakingPools[lock];
        pool.apr = apr;
        pool.minStake = minStake;
        pool.maxStake = maxStake;
        pool.totalMaxStakeAmount = totalMaxStakeAmount;
        pool.active = active;

        emit StakingPoolCreated(lock, apr, minStake, maxStake, totalMaxStakeAmount, active);
    }

    /**
     * @dev Sets the contract's operational state.
     * @param newState The new state to set the contract to (0 for OFF, 1 for OPEN).
     */
    function setContractState(uint256 newState) external onlyOwner {
        require(newState < 2, "Invalid State!");
        contractState = ContractState(newState);
    }

    /**
     * @dev Sets the USDB ERC20 token contract.
     * @param _EMRLD The address of the EMRLD ERC20 token contract.
     */
    function setEMRLD(address _EMRLD) external onlyOwner {
        EMRLD = IERC20Metadata(_EMRLD);
    }

    ///
    /// MISC
    ///
    
    /**
     * @notice Withdraws Ether from the contract.
     * @param recipient The address to receive the Ether.
     * @param amount The amount of Ether to withdraw.
     */
    function withdrawEther(address recipient, uint256 amount) external onlyOwner {
        require(recipient != address(0), "Invalid Address!");
        require(amount > 0 && address(this).balance >= amount, "Invalid Amount!");

        (bool sent, ) = recipient.call{value: amount}("");
        require(sent, "Failed to send Ether");
    }

    /**
     * @notice Withdraws ERC20 tokens from the contract.
     * @param recipient The address to receive the tokens.
     * @param amount The amount of tokens to withdraw.
     * @param token The address of the token contract.
     */
    function withdrawToken(address recipient, uint256 amount, address token) external onlyOwner {
        require(recipient != address(0), "Invalid Address!");
        require(amount > 0, "Invalid Amount!");
        require(token != address(0), "Invalid Token!");

        require(IERC20(token).transfer(recipient, amount), "Unsuccessful Transfer!");
    }
}

Read Contract

EMRLD 0x72706a8c → address
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
calculateReward 0x1852e8d9 → uint256
contractState 0x85209ee0 → uint8
decimals 0x313ce567 → uint8
name 0x06fdde03 → string
owner 0x8da5cb5b → address
stakes 0x584b62a1 → uint256, uint256, bool
stakingPools 0x5aad6cf0 → uint256, uint256, uint256, uint256, uint256, uint256, bool
symbol 0x95d89b41 → string
tokensClaimed 0x624601b6 → uint256
totalSupply 0x18160ddd → uint256

Write Contract 14 functions

These functions modify contract state and require a wallet transaction to execute.

approve 0x095ea7b3
address spender
uint256 value
returns: bool
emergencyUnstake 0x4268121e
address user
uint256 lock
renounceOwnership 0x715018a6
No parameters
restake 0xbce1b520
uint256 lock
setContractState 0xfb7265ff
uint256 newState
setEMRLD 0x5733c786
address _EMRLD
setStakingPool 0xca3c782c
uint256 lock
uint256 apr
uint256 minStake
uint256 maxStake
uint256 totalMaxStakeAmount
bool active
stake 0x7b0472f0
uint256 lock
uint256 amount
transfer 0xa9059cbb
address to
uint256 value
returns: bool
transferFrom 0x23b872dd
address from
address to
uint256 value
returns: bool
transferOwnership 0xf2fde38b
address newOwner
unstake 0x2e17de78
uint256 lock
withdrawEther 0x522f6815
address recipient
uint256 amount
withdrawToken 0x3ccdbb28
address recipient
uint256 amount
address token

Recent Transactions

No transactions found for this address