BSC链上主流的代币模式越发的丰富起来,下面提供一份包含当前主流的代币模式的合约代码。包括:通缩燃烧+限制通缩+基金会地址回流+加池分红。具体模式功能详细介绍如下:
1、通缩燃烧:单向通缩,只在买币时通缩,卖币时不通缩,保证用户兑换代币时可以获得实际的bnb收益。线下转账时通缩,增加代币的燃烧销毁速率。每笔交易都会有4%的代币被燃烧掉。币的总量随着燃烧逐级减少。在区块链浏览器上可以查询代币的总量逐级减少。
2、限制通缩:当代币燃烧到一定数量以后,停止通缩,恒定流通。
3、基金会地址回流:每笔交易都会有部分比例的代币回流到资金池地址,资金池地址的代币可以用于社区推广,运营,项目开发等,正向促进项目的良性发展。合约代码中是2%回流资金池地址。
4、加池分红:用户添加流动性,除了获得代币价格增长产生的收益外,还可以额外获取每笔交易4%的代币数量回流到资金池,根据用户加池占据资金池体量的比例,获得对应的加池分红。
本合约代码仅供学习研究交流区块链技术使用,不得用于商业用途。任何违规或者违法使用该合约代码造成的后果和作者没有任何关系。本作者不承担任何法律责任,特此声明。
具体合约代码如下:
接口文件:IERC20.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; /** * @title ERC20 interface */ interface IERC20 { function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); }
SafeMath.sol(数学安全算法文件)
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; /** * @title SafeMath * @dev Unsigned math operations with safety checks that revert on error */ library SafeMath { /** * @dev Multiplies two unsigned integers, reverts on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath#mul: OVERFLOW"); return c; }
Context.sol(上下文文件)
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
Ownable.sol (属主文件)
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; import "./Context.sol"; contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; }
Token.sol(代币合约文件)
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; import "./IERC20.sol"; import "./Context.sol"; import "./Ownable.sol"; import "./SafeMath.sol"; contract Token is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; string private _name = 'SH TOKEN'; string private _symbol = 'SH'; uint8 private _decimals = 6; uint256 private _totalSupply = 88888 * 10**uint256(_decimals); address private _burnPool = address(0); address private _fundAddress; uint256 public _burnFee = 4; uint256 private _previousBurnFee = _burnFee; uint256 public _liquidityFee = 4; uint256 private _previousLiquidityFee = _liquidityFee; uint256 public _fundFee = 2; uint256 private _previousFundFee = _fundFee; uint256 public MAX_STOP_FEE_TOTAL = 8888 * 10**uint256(_decimals); mapping(address => bool) private _isExcludedFromFee; uint256 private _burnFeeTotal; uint256 private _liquidityFeeTotal; uint256 private _fundFeeTotal; bool private inSwapAndLiquify = false; bool public swapAndLiquifyEnabled = true; address public _exchangePool; uint256 public constant delay = 15 minutes; event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 trxReceived, uint256 tokensIntoLiqudity ); event InitLiquidity( uint256 tokensAmount, uint256 trxAmount, uint256 liqudityAmount ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (address fundAddress) public { _fundAddress = fundAddress; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _balances[_msgSender()] = _totalSupply; emit Transfer(address(0), _msgSender(), _totalSupply); } receive () external payable {}
代币部署时动态输入基金会地址。
上线pancakeswap薄饼交易所后,获取资金池地址,动态传入合约,完成加池分红。
至此,完成通缩燃烧加池分红基金会地址回流合约代码的所有操作流程。
pdf+视频币安智能链BSC发币教程及多模式组合合约源代码下载:
多模式(燃烧、回流指定营销地址、分红本币及任意币种,邀请推广八代收益,LP加池分红、交易分红、复利分红、NFT分红、自动筑池、动态手续费、定时开盘、回购)组合合约源代码下载:
pdf+视频币安智能链BSC发币教程及多模式组合合约源代码下载地址:
添加VX或者telegram获取全程线上免费指导
评论前必须登录!
注册