Source Code
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
MultipleTimeLock
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract MultipleTimeLock {
struct TimeLock {
address token;
uint256 releaseTime;
}
mapping(address => TimeLock) public timeLocks;
address public immutable beneficiary;
/**
* @dev Check if the given address is the beneficiary
*/
modifier onlyBeneficiary() {
require(msg.sender == beneficiary, "onlyBeneficiary");
_;
}
/**
* @dev Deploys a timelock instance that is able to hold tokens and will only release them to the deployer after the releaseTime
*/
constructor() {
beneficiary = msg.sender;
}
/**
* @dev Create a timelock instance for one token. Could be called only one time by token
*/
function addTimeLock(address _token, uint256 _releaseTime) public onlyBeneficiary {
require(_releaseTime > block.timestamp, "release time is before current time");
TimeLock storage timeLock = timeLocks[_token];
require(timeLocks[_token].token == address(0), "TimeLock already exist for this token");
timeLock.token = _token;
timeLock.releaseTime = _releaseTime;
}
/**
* @dev Increase the lock, can never be lower than the previous config
*/
function increaseTimeLock(address _token, uint256 _releaseTime) public onlyBeneficiary {
require(_releaseTime > block.timestamp, "release time is before current time");
TimeLock storage timeLock = timeLocks[_token];
require(timeLocks[_token].token == _token, "TimeLock not exist");
require(_releaseTime > timeLock.releaseTime, "release time is before the current lock time");
timeLock.releaseTime = _releaseTime;
}
/**
* @dev Transfers tokens held by the timelock to the beneficiary. Will only succeed if invoked after the release
* time.
*/
function release(address _token) public onlyBeneficiary {
TimeLock memory timeLock = timeLocks[_token];
require(block.timestamp >= timeLock.releaseTime, "current time is before release time");
uint256 amount = IERC20(_token).balanceOf(address(this));
require(amount > 0, "no tokens to release");
IERC20(_token).transfer(beneficiary, amount);
}
function getTimeLock(address _token) external view returns (TimeLock memory) {
return timeLocks[_token];
}
}// SPDX-License-Identifier: MIT
// 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);
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_releaseTime","type":"uint256"}],"name":"addTimeLock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"beneficiary","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"getTimeLock","outputs":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"releaseTime","type":"uint256"}],"internalType":"struct MultipleTimeLock.TimeLock","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_releaseTime","type":"uint256"}],"name":"increaseTimeLock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"release","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"timeLocks","outputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"releaseTime","type":"uint256"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60a060405234801561001057600080fd5b503360805260805161076361004b600039600081816094015281816101bd01528181610360015281816103ed015261052301526107636000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c8063191655871461006757806323bc1f471461007c57806338af3eed1461008f5780634c7c7160146100d3578063748f7098146100e65780637f76b22314610160575b600080fd5b61007a61007536600461063a565b6101b2565b005b61007a61008a36600461065c565b6103e2565b6100b67f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b61007a6100e136600461065c565b610518565b61013c6100f436600461063a565b604080518082018252600080825260209182018190526001600160a01b0393841681528082528290208251808401909352805490931682526001909201549181019190915290565b6040805182516001600160a01b0316815260209283015192810192909252016100ca565b61019361016e36600461063a565b600060208190529081526040902080546001909101546001600160a01b039091169082565b604080516001600160a01b0390931683526020830191909152016100ca565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146102035760405162461bcd60e51b81526004016101fa90610686565b60405180910390fd5b6001600160a01b0380821660009081526020818152604091829020825180840190935280549093168252600190920154918101829052904210156102955760405162461bcd60e51b815260206004820152602360248201527f63757272656e742074696d65206973206265666f72652072656c656173652074604482015262696d6560e81b60648201526084016101fa565b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a0823190602401602060405180830381865afa1580156102dc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061030091906106af565b9050600081116103495760405162461bcd60e51b81526020600482015260146024820152736e6f20746f6b656e7320746f2072656c6561736560601b60448201526064016101fa565b60405163a9059cbb60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301526024820183905284169063a9059cbb906044016020604051808303816000875af11580156103b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103dc91906106c8565b50505050565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461042a5760405162461bcd60e51b81526004016101fa90610686565b4281116104495760405162461bcd60e51b81526004016101fa906106ea565b6001600160a01b0380831660008181526020819052604090208054909216146104a95760405162461bcd60e51b8152602060048201526012602482015271151a5b59531bd8dac81b9bdd08195e1a5cdd60721b60448201526064016101fa565b806001015482116105115760405162461bcd60e51b815260206004820152602c60248201527f72656c656173652074696d65206973206265666f72652074686520637572726560448201526b6e74206c6f636b2074696d6560a01b60648201526084016101fa565b6001015550565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146105605760405162461bcd60e51b81526004016101fa90610686565b42811161057f5760405162461bcd60e51b81526004016101fa906106ea565b6001600160a01b0380831660009081526020819052604090208054909116156105f85760405162461bcd60e51b815260206004820152602560248201527f54696d654c6f636b20616c726561647920657869737420666f722074686973206044820152643a37b5b2b760d91b60648201526084016101fa565b80546001600160a01b0319166001600160a01b0393909316929092178255600190910155565b80356001600160a01b038116811461063557600080fd5b919050565b60006020828403121561064c57600080fd5b6106558261061e565b9392505050565b6000806040838503121561066f57600080fd5b6106788361061e565b946020939093013593505050565b6020808252600f908201526e6f6e6c7942656e656669636961727960881b604082015260600190565b6000602082840312156106c157600080fd5b5051919050565b6000602082840312156106da57600080fd5b8151801515811461065557600080fd5b60208082526023908201527f72656c656173652074696d65206973206265666f72652063757272656e742074604082015262696d6560e81b60608201526080019056fea2646970667358221220060952d0fef832982a82c66ccb84782d249cf0cf60bd9aef59e4eb2398fac96764736f6c63430008110033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100625760003560e01c8063191655871461006757806323bc1f471461007c57806338af3eed1461008f5780634c7c7160146100d3578063748f7098146100e65780637f76b22314610160575b600080fd5b61007a61007536600461063a565b6101b2565b005b61007a61008a36600461065c565b6103e2565b6100b67f0000000000000000000000001cff9fbbea125a9d5eb32c6bcaa147756ad0066a81565b6040516001600160a01b0390911681526020015b60405180910390f35b61007a6100e136600461065c565b610518565b61013c6100f436600461063a565b604080518082018252600080825260209182018190526001600160a01b0393841681528082528290208251808401909352805490931682526001909201549181019190915290565b6040805182516001600160a01b0316815260209283015192810192909252016100ca565b61019361016e36600461063a565b600060208190529081526040902080546001909101546001600160a01b039091169082565b604080516001600160a01b0390931683526020830191909152016100ca565b336001600160a01b037f0000000000000000000000001cff9fbbea125a9d5eb32c6bcaa147756ad0066a16146102035760405162461bcd60e51b81526004016101fa90610686565b60405180910390fd5b6001600160a01b0380821660009081526020818152604091829020825180840190935280549093168252600190920154918101829052904210156102955760405162461bcd60e51b815260206004820152602360248201527f63757272656e742074696d65206973206265666f72652072656c656173652074604482015262696d6560e81b60648201526084016101fa565b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a0823190602401602060405180830381865afa1580156102dc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061030091906106af565b9050600081116103495760405162461bcd60e51b81526020600482015260146024820152736e6f20746f6b656e7320746f2072656c6561736560601b60448201526064016101fa565b60405163a9059cbb60e01b81526001600160a01b037f0000000000000000000000001cff9fbbea125a9d5eb32c6bcaa147756ad0066a811660048301526024820183905284169063a9059cbb906044016020604051808303816000875af11580156103b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103dc91906106c8565b50505050565b336001600160a01b037f0000000000000000000000001cff9fbbea125a9d5eb32c6bcaa147756ad0066a161461042a5760405162461bcd60e51b81526004016101fa90610686565b4281116104495760405162461bcd60e51b81526004016101fa906106ea565b6001600160a01b0380831660008181526020819052604090208054909216146104a95760405162461bcd60e51b8152602060048201526012602482015271151a5b59531bd8dac81b9bdd08195e1a5cdd60721b60448201526064016101fa565b806001015482116105115760405162461bcd60e51b815260206004820152602c60248201527f72656c656173652074696d65206973206265666f72652074686520637572726560448201526b6e74206c6f636b2074696d6560a01b60648201526084016101fa565b6001015550565b336001600160a01b037f0000000000000000000000001cff9fbbea125a9d5eb32c6bcaa147756ad0066a16146105605760405162461bcd60e51b81526004016101fa90610686565b42811161057f5760405162461bcd60e51b81526004016101fa906106ea565b6001600160a01b0380831660009081526020819052604090208054909116156105f85760405162461bcd60e51b815260206004820152602560248201527f54696d654c6f636b20616c726561647920657869737420666f722074686973206044820152643a37b5b2b760d91b60648201526084016101fa565b80546001600160a01b0319166001600160a01b0393909316929092178255600190910155565b80356001600160a01b038116811461063557600080fd5b919050565b60006020828403121561064c57600080fd5b6106558261061e565b9392505050565b6000806040838503121561066f57600080fd5b6106788361061e565b946020939093013593505050565b6020808252600f908201526e6f6e6c7942656e656669636961727960881b604082015260600190565b6000602082840312156106c157600080fd5b5051919050565b6000602082840312156106da57600080fd5b8151801515811461065557600080fd5b60208082526023908201527f72656c656173652074696d65206973206265666f72652063757272656e742074604082015262696d6560e81b60608201526080019056fea2646970667358221220060952d0fef832982a82c66ccb84782d249cf0cf60bd9aef59e4eb2398fac96764736f6c63430008110033
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 33 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.