简体   繁体   English

已铸造代币的众筹 (BEP20)

[英]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:您可以添加更多功能,例如:

  • max order per address每个地址的最大订单
  • manually or dynamically adjusted pricing手动或动态调整定价
  • being able to withdraw the tokens back from the contract to a predefined address能够将代币从合约中撤回到预定义的地址
  • validation if the crowdsale contract has sufficient token balance (so that it fails with a custom error message in case of insuficient balance)验证众筹合约是否有足够的代币余额(以便在余额不足的情况下失败并显示自定义错误消息)
  • etc... ETC...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM