简体   繁体   English

如何将代币经济学添加到 ERC20 代币?

[英]How to add tokenomics to a ERC20 token?

I have taken different courses and even tho they explain how to make a token I haven't been able to learn how to implement tokenomics.我参加了不同的课程,即使他们解释了如何制作代币,我也无法学习如何实施代币经济学。

For example fees for transactions, burning to LP etc...例如交易费用、烧录到 LP 等...

I leave a link to the openzeppelin standard我留下了 openzeppelin 标准的链接

Would be great to have some more detailed examples on it.有一些更详细的例子会很棒。

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol

syncastra.同步。 So basically what you are looking for is to make a custom _transfer() method by overriding the one provided in the openzeppelin ERC20 standard.因此,基本上您正在寻找的是通过覆盖 openzeppelin ERC20 标准中提供的方法来制作自定义 _transfer() 方法。 You can check at "OXB" (oxbull.tech) token, which implements this type of fee, but basically, you just take tokens from the sender, before sending them to the receiver, and once you are done charging the fees you can send the left tokens to the receiver.您可以查看实现此类费用的“OXB”(oxbull.tech)令牌,但基本上,您只需从发送者那里获取令牌,然后将它们发送给接收者,一旦您完成收取费用,您就可以发送给接收者留下的令牌。 An example would be:一个例子是:

function _transfer(address sender, address recipient, uint256 amount) private {
    require(sender != address(0), "BEP20: transfer from the zero address");
    require(balanceOf(sender) >= amount, "BEP2': not enough balance");
    
    uint256 tokensToBurn = amount.mul(burningFee).div(100);
    amount = amount.sub(tokensToBurn);

    balances[sender] = balances[sender].sub(amount);

    _burn(sender, tokensToBurn);
    balances[recipient] = balances[recipient].add(amount);
    
}

Options of what you can do are infinite.你能做的选择是无限的。 Hope this is helpful.希望这会有所帮助。

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

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