目前数字货币发行已经不仅仅局限于可以实现基本的转账功能,多种模式的合约代码不断更新出现。defi也正是因为数字通证的多样化发展变得活力巨大。合约代码的不断更新增强了defi的可操作性和智能化。币安bsc智能链加pancakeswap博饼,火币heco加mdex,波场trx加justswap代币发行模式是类型的,bsc和heco都是基于ERC20,波场是基于TRC20,但是实现的标准都是ERC标准,合约代码具有部分通用性。
目前的合约主要包括如下几个模式:通缩、燃烧、回流、指定地址转入、自动加池子、黑洞销毁、持币分红、权重分红、平均分红等。而这些模式的合约代码基本都具备通用性,在学习研究时可以通过修改其中的部分参数值来调整模式比例,熟悉每个参数的含义,有利用增加对区块链的学习深入能力。
从数字货币的流向来说其实大致就分如下几种:指定地址转入包括黑洞地址、交易手续费分红。举例比如6%的交易通缩,其中2%作为交易手续费加权分红到所有持币用户,1%燃烧掉转入黑洞地址,3%转入指定用户地址。其中加权分红是按照每个公钥地址的持币量的权重来分红代币。
如下提供一个完整的通缩实例代码:6%通缩(2%交易费加权分红+1%黑洞燃烧+3%基金会地址转入):
contract Token is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 100000 * 10**6; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _tBurnTotal; uint256 public _taxFee = 2; uint256 private _previousTaxFee = _taxFee; uint256 public _burnFee = 1; uint256 private _previousBurnFee = _burnFee; uint256 public _fundFee = 3; uint256 private _previousFundFee = _fundFee; uint256 public MAX_STOP_FEE_TOTAL = 1000 * 10**uint256(_decimals); constructor () public { _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(_tTotal <= MAX_STOP_FEE_TOTAL) { removeAllFee(); _transferStandard(sender, recipient, amount); } else { if(_isExcludedFromFee[sender]) removeAllFee(); _transferStandard(sender, recipient, amount); if(_isExcludedFromFee[sender]) restoreAllFee(); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn, uint256 tFund) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _rOwned[fundAddress] = _rOwned[fundAddress].add(tFund.mul(currentRate)); _reflectFee(rFee, tBurn.mul(currentRate), tFee, tBurn); emit Transfer(sender, recipient, tTransferAmount); emit Transfer(sender, _burnPool, tBurn); emit Transfer(sender, fundAddress, tFund); }
pdf+视频币安智能链BSC发币教程及多模式组合合约源代码下载:
多模式(燃烧、回流指定营销地址、分红本币及任意币种,邀请推广八代收益,LP加池分红、交易分红、复利分红、NFT分红、自动筑池、动态手续费、定时开盘、回购)组合合约源代码下载:
pdf+视频币安智能链BSC发币教程及多模式组合合约源代码下载地址:
添加VX或者telegram获取全程线上免费指导
评论前必须登录!
注册