Address Contract Partially Verified
Address
0x13Fe7160858F2A16b8e4429DFf26c8a3A4b12b1B
Balance
0 ETH
Nonce
1
Code Size
4180 bytes
Creator
0x505B5eDa...Bf04 at tx 0x855b19e0...7d3842
Indexed Transactions
0
Contract Bytecode
4180 bytes
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c80637b14fcf611610097578063d87c10be11610066578063d87c10be1461024c578063e97d87d51461025f578063ec715a3114610268578063f71ad68e1461027057600080fd5b80637b14fcf6146101ca5780639ad13d96146101dd578063afc3e72e14610226578063c01c4cfc1461023957600080fd5b80631fb01587116100d35780631fb01587146101715780632066d8781461019c57806355a373d6146101af5780636fcf06f1146101c257600080fd5b806301567739146100fa5780630c4db24d146101455780631398c3271461015c575b600080fd5b61012d610108366004610e23565b60046020526000908152604090208054600182015460029092015460ff909116919083565b60405161013c93929190610e7d565b60405180910390f35b61014e60025481565b60405190815260200161013c565b61016f61016a366004610e9c565b610283565b005b600654610184906001600160a01b031681565b6040516001600160a01b03909116815260200161013c565b61016f6101aa366004610e23565b61044c565b600054610184906001600160a01b031681565b61016f61054d565b61016f6101d8366004610e23565b610650565b61020b6101eb366004610ed5565b600160208190526000918252604090912080549181015460029091015483565b6040805193845260208401929092529082015260600161013c565b61016f610234366004610e23565b610752565b600554610184906001600160a01b031681565b600754610184906001600160a01b031681565b61014e60035481565b61016f610854565b61016f61027e366004610ef0565b610b3b565b6005546001600160a01b03163314806102a657506006546001600160a01b031633145b806102bb57506007546001600160a01b031633145b61030c5760405162461bcd60e51b815260206004820152601360248201527f4f6e6c792061646d696e7320616c6c6f7765640000000000000000000000000060448201526064015b60405180910390fd5b80600254101561035e5760405162461bcd60e51b815260206004820152601a60248201527f4e6f7420656e6f75676820746f6b656e206176616c6961626c650000000000006044820152606401610303565b80600260008282546103709190610f42565b9091555050604080516001600160a01b0384168152602081018390527feec8d93f23b05d0f7682e69bd12d081c1fdf167e91bf593fd9b9e7ff741f57ed910160405180910390a16000546040517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b038481166004830152602482018490529091169063a9059cbb906044016020604051808303816000875af1158015610423573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104479190610f59565b505050565b6005546001600160a01b031633148061046f57506006546001600160a01b031633145b8061048457506007546001600160a01b031633145b6104d05760405162461bcd60e51b815260206004820152601360248201527f4f6e6c792061646d696e7320616c6c6f776564000000000000000000000000006044820152606401610303565b6005546001600160a01b0382811691161461054a576040516001600160a01b03821681527fc5a43ddba1724d0ee35d212371c8783751682ec96ecca48138a6bebe87837c059060200160405180910390a16005805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383161790555b50565b6005546001600160a01b031633148061057057506006546001600160a01b031633145b8061058557506007546001600160a01b031633145b6105d15760405162461bcd60e51b815260206004820152601360248201527f4f6e6c792061646d696e7320616c6c6f776564000000000000000000000000006044820152606401610303565b600354156106215760405162461bcd60e51b815260206004820181905260248201527f52656c656173652074696d652068617320616c726561647920737461727465646044820152606401610303565b426003556040517fb2970d659ef3ac60e87bd9f4fde5ecc082d5f14946b5c6f509bad4954a99731a90600090a1565b6005546001600160a01b031633148061067357506006546001600160a01b031633145b8061068857506007546001600160a01b031633145b6106d45760405162461bcd60e51b815260206004820152601360248201527f4f6e6c792061646d696e7320616c6c6f776564000000000000000000000000006044820152606401610303565b6007546001600160a01b0382811691161461054a576040516001600160a01b03821681527f9a73b853d7e0d4401faf3d43710a0bc28e4cea4991dc955aec45fa1f466aa69d9060200160405180910390a1600780546001600160a01b03831673ffffffffffffffffffffffffffffffffffffffff1990911617905550565b6005546001600160a01b031633148061077557506006546001600160a01b031633145b8061078a57506007546001600160a01b031633145b6107d65760405162461bcd60e51b815260206004820152601360248201527f4f6e6c792061646d696e7320616c6c6f776564000000000000000000000000006044820152606401610303565b6006546001600160a01b0382811691161461054a576040516001600160a01b03821681527fd6d3af45177bc59b97d870b43a686cd537b82c80922178a602e27045dc3002029060200160405180910390a1600680546001600160a01b03831673ffffffffffffffffffffffffffffffffffffffff1990911617905550565b6000600354116108a65760405162461bcd60e51b815260206004820181905260248201527f52656c656173652074696d6520686173206e6f742073746172746564207965746044820152606401610303565b336000908152600460205260408082208151606081019092528054829060ff1660088111156108d7576108d7610e45565b60088111156108e8576108e8610e45565b8152600182015460208201526002909101546040918201528101519091506109785760405162461bcd60e51b815260206004820152603760248201527f4164647265737320646f65736e742062656c6f6e6720746f20612062656e656660448201527f6963696172792073657420627920616e2061646d696e2e0000000000000000006064820152608401610303565b6000600160008360000151600881111561099457610994610e45565b60088111156109a5576109a5610e45565b815260200190815260200160002060405180606001604052908160008201548152602001600182015481526020016002820154815250509050600060035482600001516109f29190610f7b565b9050600080824210610a6657610a088342610f42565b91508360400151821015610a1e57836040015191505b83602001518210610a3157836020015191505b6020840151610a4557506040840151610a66565b60208401516040860151610a599084610f93565b610a639190610fd0565b90505b6000856020015182610a789190610f42565b33600090815260046020526040812060010180549293508392909190610a9f908490610f7b565b90915550506000546040517fa9059cbb000000000000000000000000000000000000000000000000000000008152336004820152602481018390526001600160a01b039091169063a9059cbb906044016020604051808303816000875af1158015610b0e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b329190610f59565b50505050505050565b6005546001600160a01b0316331480610b5e57506006546001600160a01b031633145b80610b7357506007546001600160a01b031633145b610bbf5760405162461bcd60e51b815260206004820152601360248201527f4f6e6c792061646d696e7320616c6c6f776564000000000000000000000000006044820152606401610303565b816002541015610c115760405162461bcd60e51b815260206004820152601860248201527f4e6f7420656e6f75676820746f6b656e20746f20626f6f6b00000000000000006044820152606401610303565b6001600160a01b03831660009081526004602052604090206002015415610ca05760405162461bcd60e51b815260206004820152602260248201527f42656e656669636961726965732063616e206f6e6c7920626520736574206f6e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610303565b60008211610d165760405162461bcd60e51b815260206004820152603960248201527f4d6f7265207468616e203020746f6b656e206e6565647320746f20626520626f60448201527f6f6b656420746f2073657420612062656e6566696369617279000000000000006064820152608401610303565b8160026000828254610d289190610f42565b90915550506040517ffd654da5fd4bc4ed30e1d98b165d78387a0d91a3721f65683c3f399f160d786c90610d6190859085908590610ff2565b60405180910390a16040518060600160405280826008811115610d8657610d86610e45565b81526000602080830182905260409283018690526001600160a01b038716825260049052208151815482907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001836008811115610de757610de7610e45565b021790555060208201516001820155604090910151600290910155505050565b80356001600160a01b0381168114610e1e57600080fd5b919050565b600060208284031215610e3557600080fd5b610e3e82610e07565b9392505050565b634e487b7160e01b600052602160045260246000fd5b60098110610e7957634e487b7160e01b600052602160045260246000fd5b9052565b60608101610e8b8286610e5b565b602082019390935260400152919050565b60008060408385031215610eaf57600080fd5b610eb883610e07565b946020939093013593505050565b803560098110610e1e57600080fd5b600060208284031215610ee757600080fd5b610e3e82610ec6565b600080600060608486031215610f0557600080fd5b610f0e84610e07565b925060208401359150610f2360408501610ec6565b90509250925092565b634e487b7160e01b600052601160045260246000fd5b600082821015610f5457610f54610f2c565b500390565b600060208284031215610f6b57600080fd5b81518015158114610e3e57600080fd5b60008219821115610f8e57610f8e610f2c565b500190565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615610fcb57610fcb610f2c565b500290565b600082610fed57634e487b7160e01b600052601260045260246000fd5b500490565b6001600160a01b038416815260208101839052606081016110166040830184610e5b565b94935050505056fea2646970667358221220598c1a6d1e043b35fb86098548c62e2b39d8733f08f58edfd8319582b53959af64736f6c634300080a0033
Verified Source Code Partial Match
Compiler: v0.8.10+commit.fc410830
EVM: london
Optimization: Yes (2000 runs)
TokenReleaser.sol 320 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// We'll actually use ERC777, but any IERC20 instance (including ERC777)
// is supported.
import 'openzeppelin-solidity/contracts/token/ERC20/IERC20.sol';
contract TokenReleaser {
/////////////////////////////////////////////////////////////////////////////////////////////////////
// This smart contract is divided into 3 parts:
//
// - The first part defines the different types of releases (i.e token release for seed round investor,
// token release for team and advisor ...etc). Here we define the `ReleaseType` and `ReleaseSchedule`
// types, and the function `setTokenomics` which associate to each ReleaseType its associated
// `ReleaseSchedule`. The association between the type of release and its schedule is what we call
// the `tokenomic`. Notice `setTokenomics` is called only once, therefore `tokenomic` behaves like
// a constant (unfortunately, due to solidity limitations it couldn't get declared as such).
//
// - Second part defines the `Beneficiary`, which represent an user (or more generally an address),
// that got some tokens booked; and the external function `releaseToken`. A beneficiary will call
// `releaseToken` to receive tokens, which will be sent according to the Beneficiary's release
// schedule type. Notice `releaseToken` is the only public function a non-admin user can call.
//
// - The third part defines the admins, and the action they control. Each of these actions
// is represented by a function and an Event. For security and simplicity reason, we've decide
// to keep a fixed max number of admins, 3 of them specifically (though by default we only enable 2
// of them). At any time, any admin can modify the list of admins.
//
// Types, variables and events are defined right before they are mentioned on code.
IERC20 public tokenContract;
constructor(address _adminA, address _adminB, IERC20 _contract, uint256 avaliableTokens){
tokenContract = _contract;
adminA = _adminA;
adminB = _adminB;
setTokenomics(avaliableTokens);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// First part:
enum ReleaseType
{ SEED_ROUND
, PRIVATE_ROUND
, STRATEGIC_ROUND
, PUBLIC_SALE
, COMPANY_RESERVE
, TEAM_AND_ADVISORS
, STRATEGIC_PARTNERS
, FOUNDERS_AND_EARLY_CONTRIBUTORS
, MINING_RESERVE
}
// Information about how an specific ReleaseType will be scheduled.
struct ReleaseSchedule
{ uint256 tokenLockTime ; // lockup time after the release time starts.
uint256 tokenReleaseDuration ; // vesting time during which the token will be gradually released.
// if 0, it means everything available at once.
uint256 immediateAccessTimeWindow ; // When the release time starts, the beneficiary will have immediate access to
} // all the tokens to be released to him during the his `immediateAccessTimeWindow`.
mapping(ReleaseType => ReleaseSchedule) public tokenomic;
uint256 public avaliableTokensToRelease;
// Defines the total amount of tokens available to get release, and how the schedule
// for each type of release will be.
function setTokenomics(uint256 avaliableTokens) private{
// NOTICE: we take a month to be equivalent to 30 days, regardless of actual calendar months.
// In particular, 12 month would not sum up a whole year, but 360 days.
tokenomic[ ReleaseType.SEED_ROUND ] = ReleaseSchedule
({ tokenLockTime : 0 * 30 days
, tokenReleaseDuration : 24 * 30 days
, immediateAccessTimeWindow : 1 * 30 days
}
);
tokenomic[ ReleaseType.PRIVATE_ROUND ] = ReleaseSchedule
({ tokenLockTime : 0 * 30 days
, tokenReleaseDuration : 12 * 30 days
, immediateAccessTimeWindow : 1 * 30 days
}
);
tokenomic[ ReleaseType.STRATEGIC_ROUND ] = ReleaseSchedule
({ tokenLockTime : 0 * 30 days
, tokenReleaseDuration : 12 * 30 days
, immediateAccessTimeWindow : 1 * 30 days
}
);
tokenomic[ ReleaseType.PUBLIC_SALE ] = ReleaseSchedule
({ tokenLockTime : 0 * 30 days
, tokenReleaseDuration : 0 * 30 days
, immediateAccessTimeWindow : 0 * 30 days
} // as `tokenReleaseDuration == 0` everything is available as soon as the release time starts.
);
tokenomic[ ReleaseType.COMPANY_RESERVE ] = ReleaseSchedule
({ tokenLockTime : 0 * 30 days
, tokenReleaseDuration : 36 * 30 days
, immediateAccessTimeWindow : 1 * 30 days
}
);
tokenomic[ ReleaseType.TEAM_AND_ADVISORS ] = ReleaseSchedule
({ tokenLockTime : 12 * 30 days
, tokenReleaseDuration : 36 * 30 days
, immediateAccessTimeWindow : 0 * 30 days
}
);
tokenomic[ ReleaseType.STRATEGIC_PARTNERS ] = ReleaseSchedule
({ tokenLockTime : 12 * 30 days
, tokenReleaseDuration : 36 * 30 days
, immediateAccessTimeWindow : 0 * 30 days
}
);
tokenomic[ ReleaseType.FOUNDERS_AND_EARLY_CONTRIBUTORS] = ReleaseSchedule
({ tokenLockTime : 12 * 30 days
, tokenReleaseDuration : 48 * 30 days
, immediateAccessTimeWindow : 0 * 30 days
}
);
tokenomic[ ReleaseType.MINING_RESERVE ] = ReleaseSchedule
({ tokenLockTime : 6 * 30 days
, tokenReleaseDuration : 60 * 30 days
, immediateAccessTimeWindow : 0 * 30 days
}
);
avaliableTokensToRelease = avaliableTokens;
}
//////////////////////////////////////////////////////////////////////////////////////////
// Second Part:
struct Beneficiary
{ ReleaseType releaseSchedule ; // public sale, seed round ...
uint256 tokensAlreadyReleased ;
uint256 tokenBookedAmount ;
}
uint256 public releaseStartTime;
mapping(address => Beneficiary) public beneficiaries;
function releaseToken() external{
require( releaseStartTime > 0
, 'Release time has not started yet'
)
;
Beneficiary memory beneficiary = beneficiaries[msg.sender];
require( beneficiary.tokenBookedAmount != 0
, 'Address doesnt belong to a beneficiary set by an admin.'
)
;
ReleaseSchedule memory releaseSchedule = tokenomic[beneficiary.releaseSchedule];
// Date the tokens locktime finish for the beneficiary.
uint256 startTime = releaseSchedule.tokenLockTime + releaseStartTime;
// After the locktime has finished, there's a time window defined as `tokenReleaseDuration`.
// `timeCompleted` is how much of that time window has been completed.
// A beneficiary can only release a fraction of his token proportional to how much of this time window
// has been completed (or the totality of them if it is completed).
uint256 timeCompleted = 0;
uint256 unlockedTokens = 0;
if (block.timestamp >= startTime){
timeCompleted = block.timestamp - startTime;
// Time completed is the maximum between the time it has passed since start, and
// the immediateAccessTimeWindow, capped to a max of tokenReleaseDuration.
if (timeCompleted < releaseSchedule.immediateAccessTimeWindow){
timeCompleted = releaseSchedule.immediateAccessTimeWindow;
}
if (timeCompleted >= releaseSchedule.tokenReleaseDuration){
timeCompleted = releaseSchedule.tokenReleaseDuration;
}
// `tokenReleaseDuration == 0` means everything is available right after the release lock time
if (releaseSchedule.tokenReleaseDuration == 0){
unlockedTokens = beneficiary.tokenBookedAmount;
} else {
unlockedTokens = (timeCompleted * beneficiary.tokenBookedAmount) / releaseSchedule.tokenReleaseDuration;
}
}
uint256 toRelease = unlockedTokens - beneficiary.tokensAlreadyReleased;
beneficiaries[msg.sender].tokensAlreadyReleased += toRelease;
tokenContract.transfer( msg.sender, toRelease );
}
//////////////////////////////////////////////////////////////////////////////////////////
address public adminA; // active admin
address public adminB; // backup admin
address public adminT; // temporary admin, only used during key rotation for one of the other admins.
modifier adminOnly(){
require( (msg.sender == adminA) || (msg.sender == adminB) || (msg.sender == adminT)
, 'Only admins allowed'
)
;
_;
}
event NewAdminA(address adminA );
function changeAdminA(address newAdminA) external adminOnly{
if (adminA != newAdminA){
emit NewAdminA(newAdminA);
adminA = newAdminA;
}
// Notice we don't fail when there's not a NewAdminX defined,
// this is on purpose, so the function becomes idempotent and
// it is easier to programatically interact with while
// deployed on testnet.
}
event NewAdminB(address adminB );
function changeAdminB(address newAdminB) external adminOnly{
if (adminB != newAdminB){
emit NewAdminB(newAdminB);
adminB = newAdminB;
}
}
event NewAdminT(address adminT );
function changeAdminT(address newAdminT) external adminOnly{
if (adminT != newAdminT){
emit NewAdminT(newAdminT);
adminT = newAdminT;
}
}
event TokensBook(address beneficiary , uint256 tokenAmount, ReleaseType releaseSchedule);
function bookTokensFor( address beneficiary , uint256 tokenAmount, ReleaseType releaseSchedule) external adminOnly{
require( avaliableTokensToRelease >= tokenAmount
, 'Not enough token to book'
)
;
require( beneficiaries[beneficiary].tokenBookedAmount == 0
, 'Beneficiaries can only be set once'
)
;
require( tokenAmount > 0
, 'More than 0 token needs to be booked to set a beneficiary'
)
;
avaliableTokensToRelease -= tokenAmount;
emit TokensBook(beneficiary, tokenAmount, releaseSchedule);
beneficiaries[beneficiary] = Beneficiary(releaseSchedule,0,tokenAmount);
}
event ReleaseTimeStarted();
function startReleaseTime() external adminOnly{
require( releaseStartTime == 0
, 'Release time has already started'
)
;
releaseStartTime = block.timestamp;
emit ReleaseTimeStarted();
}
event ImmediateTokensSent(address beneficiary, uint256 amount);
// Release tokens immediately without a release schedule.
function immediateSendTokens(address beneficiary, uint256 amount) external adminOnly{
require( avaliableTokensToRelease >= amount
, 'Not enough token avaliable'
)
;
avaliableTokensToRelease -= amount;
emit ImmediateTokensSent(beneficiary, amount);
tokenContract.transfer( beneficiary, amount );
}
//////////////////////////////////////////////////////////////////////////////////////////
}
IERC20.sol 81 lines
// SPDX-License-Identifier: MIT
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);
}
Read Contract
adminA 0xc01c4cfc → address
adminB 0x1fb01587 → address
adminT 0xd87c10be → address
avaliableTokensToRelease 0x0c4db24d → uint256
beneficiaries 0x01567739 → uint8, uint256, uint256
releaseStartTime 0xe97d87d5 → uint256
tokenContract 0x55a373d6 → address
tokenomic 0x9ad13d96 → uint256, uint256, uint256
Write Contract 7 functions
These functions modify contract state and require a wallet transaction to execute.
bookTokensFor 0xf71ad68e
address beneficiary
uint256 tokenAmount
uint8 releaseSchedule
changeAdminA 0x2066d878
address newAdminA
changeAdminB 0xafc3e72e
address newAdminB
changeAdminT 0x7b14fcf6
address newAdminT
immediateSendTokens 0x1398c327
address beneficiary
uint256 amount
releaseToken 0xec715a31
No parameters
startReleaseTime 0x6fcf06f1
No parameters
Recent Transactions
No transactions found for this address