[英]Crowdsale for already minted token (BEP20)
I currently have a BEP20 token which is owned by over 50 people (and hence why I dont want to mint another token).我目前有一个 BEP20 代币,由 50 多人拥有(因此我不想再铸造另一个代币)。 I'm looking to crowdsale it to more but I don't seem to find any tutorials of how to make a crowdsale contract for an already minted token.
我希望将其众筹到更多,但我似乎没有找到任何关于如何为已经铸造的代币制作众筹合约的教程。
Can anyone show me the way?谁能给我指路? I'm a beginner at solidiy and openzepplin but I am willing to learn.
我是solidiy和openzepplin的初学者,但我愿意学习。 Thanks
谢谢
Here's a simple crowdsale contract.这是一个简单的众筹合约。 It needs to hold the tokens (you need to send them to this contract address) before users are able to buy them.
它需要持有代币(你需要将它们发送到这个合约地址),然后用户才能购买它们。
pragma solidity ^0.8;
interface IERC20 {
function transfer(address to, uint256 amount) external returns (bool);
}
contract Crowdsale {
IERC20 public token;
uint256 price; // amount of tokens per 1 ETH
constructor (address _token, uint256 _price) {
token = IERC20(_token);
price = _price;
}
function buy() external payable {
uint256 amount = price * msg.value;
token.transfer(msg.sender, amount);
}
}
You can add more features such as:您可以添加更多功能,例如:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.