关于令牌销售,我有一个问题:令牌分发是如何工作的?
举个例子:
10% for private sale
30% for public sale
20% for dev team
40% for rewards 令牌的数量将在创建令牌时转移到这些地址,还是在创建令牌后转移到这些地址?
发布于 2021-11-14 20:38:35
它依赖于令牌合约的实现,可以两者兼而有之。
例如,在创建令牌后立即将100个令牌投入公开销售,并保留另外50个令牌以供开发团队地址稍后授予:
pragma solidity ^0.8;
contract MyToken {
mapping (address => uint256) _balances;
mapping (address => Vesting) _vesting;
struct Vesting {
uint256 amount;
uint64 unlockTime;
}
constructor() {
address publicSaleAddress = address(0x123);
address devTeamAddress = address(0x456);
// set the `publicSaleAddress` balance right away
_balances[publicSaleAddress] = 100;
// don't set the `devTeamAddress` balance now
// instead, allow them to claim it after some time
uint64 deadline = uint64(block.timestamp) + 365 days;
_vesting[devTeamAddress] = Vesting(
50,
deadline
);
}
function unvest() external {
// check if they have something to unvest
require(_vesting[msg.sender].amount > 0, 'Nothing to unvest');
// check if they are allowed to unvest yet
require(_vesting[msg.sender].unlockTime >= block.timestamp, 'Not yet');
// increase their balance
_balances[msg.sender] += _vesting[msg.sender].amount;
// prevent them from claiming the balance again
_vesting[msg.sender] = Vesting(0, 0);
}
}https://stackoverflow.com/questions/69965521
复制相似问题