top of page
搜尋
作家相片Dev Swanson

如何使用智能合约发普通MEME迷因代币(非貔貅代币,安全自由买卖,可放弃权限&拥有权)

已更新:4月16日

这是这是以太坊智能合约研究员和爱好者,史旺生。虽然我们比较注重于貔貅代币,但我们今天将会讨论如何创建一个普通的可自由买卖的代币,比如非常流行的 Meme 迷因代币(迷因币是一种因币是一种源自互联网模因或具有其他幽默特征的加密货币)例如 PEPE 青蛙代币。普通的代币不是貔貅币,普通代币可以在去中心化交易所正常买卖。

 

所以今天,让我向您介绍一些关于如何创建自己的 Meme 代币(拥有可以放弃代币权限&拥有权的功能)的有用技巧。你准备好了吗?

 

[仅用于研究和测试,您可以使用此方法创建自己的代币]

 

可放弃权限&拥有权的普通迷因代币(不是貔貅代币,可放弃权限&拥有权, 完全可以安全自由买卖,易于部署, 大众容易相信且认可的网络迷因币)




第 1 部分:使用 REMIX 和 Metamask 创建代币


1.首先,在您的电脑上安装Metamask钱包 https://metamask.io/ 并创建账户/钱包。 

 

2. 浏览Remix IDE http://remix.ethereum.org/ 你需要使用Remix IDE 来部署智能合约。 

 

3. 将 metamask 连接到 REMIX IDE。单击小狐狸插件。





点击按钮来连接狐狸钱包








4.回到REMIX IDE。点击创建新文件






5.随意命名文件,记得在后面添加 .sol。例子,DevToken.sol




6. 将本文底部的代码(可放弃权限&用有权的安全自由买卖的普通迷因代币智能合约代码)复制并粘贴到空格中。 *请勿尝试更改任何代码,否则将合约无法正常运作

 

马上复制可放弃权限&用有权的安全自由买卖的普通迷因代币智能合约代码: https://www.createyourowntoken.net/zh/copy-of-supply-printing-normal-meme-t





















*合约代码在文章最下方

 

或者

 

马上复制可放弃权限&用有权的安全自由买卖的普通迷因代币智能合约代码: https://www.createyourowntoken.net/zh/copy-of-supply-printing-normal-meme-t



7. 在 Remix 中的智能合约代码 往下滑,直到到达如下图所示的这一行




8. 现在我们要做一些代币设置。




Name:(你的代币名称)*在 “xxxxx” 内写 你的代币名称

 

Symbol: (你的代币代号) *在"XXX"内写 你的代币代号

 

Decimal: 18

 

Total Supply: (代币供应) 设置你的代币总供应量,记住如果你的小数点是 18,而你想要 100 总供应量,然后输入 100000000000000000000,因为 100 + 18*0

 

在您想要的数量后添加十八个“0”(如果您将 18 设置为十进制)。比如你要发行100个代币,正确的输入应该是1000000000000000000

 

决定好后,*在 "......" 内写上 代币供应的数字



9.点击左侧图标如下图,




选择COMPILER 编译器如下,0.5.16 …








点击 compile.














10. COMPILE 编译后。单击如下所示的图标,然后在 ENVIRONMENT (环境)部分选择 Metamask狐狸(因为我们使用的是 metamask 狐狸钱包)







11. 在 合约 方面 CONTRACT,选择 DevToken 来作为合约。















12. 点击 部署 "Deploy" 按钮。













13.在您的狐狸钱包的弹出窗口中 点击 确认交易。如果那里没有任何反应,您需要将 metamask 狐狸钱包连接到 REMIX IDE。















14. 如果一切顺利,您的代币就在路上。回到 狐狸钱包metamask,进入 活动 Activity,点击 合约部署 Contract deployment。










在区块浏览器上点击查看










点击右侧【复制】图标按钮复制合约地址。






















14. 返回狐狸钱包,点击导入代币IMPORT TOKENS。













选择自定义代币CUSTOM TOKEN, 并粘贴合约地址,等待你的代币出现,然后点击添加自定义代币
























您可以使用相同的方法在 ETH 主网、币安智能链和任何其他链中发币。

 

 

🎉🎉🎉恭喜!您已成功创建自己的代币,它们就在您的钱包中!

 

 

等等朋友,我们还没有完成......还有一个更重要的步骤需要完成...

 

 

就是: Verify Contract 验证合同/合约开源



第二部分: Verify Contract 验证合约/合约开源



为什么我们需要验证合同?为什么我们不直接将我们的代币上架到任何 DEX(去中心化交易所)?

 

 

好吧,我就告诉你,验证合约的原因是为了增加代币的受欢迎程度,投资者可能会回避未经验证的代币,最终不购买任何代币。

 

 

我们开始吧!

 

 

1. 回到 metamask,进入 Activity,点击 Contract deployment。










2.在区块浏览器上点击查看 View on block explorer




点击蓝色的合约地址





3. 在此页面上,单击合约 CONTRACT












点击 验证&发布 VERIFY AND PUBLISH





4. 接下来,我们选择如下设置



Compiler Type (编译器类型) : Single File (单一文件)

 

 

Compiler version (编译版本): 0.5.16

 

 

License Type (许可证类型): No license (没有)

 

 

然后点击 继续 Continue

 

 

5.然后,回到我们的合约代码,复制粘贴到空白处




完成机器人测试并发布, Verify and Publish




6. 您应该看到如下所示的成功消息,如果没有,则出现问题,如果您未能收到此消息,则需要重新检查所有步骤。





恭喜!您的合同现已通过验证,您可以在去中心化交易所 (DEX) 上你的代币了。

 

如果你使用以太坊主网,请使用 Uniswap,链接:https://app.uniswap.org/#/swap

 

如果您使用 BSC(币安智能链),请使用 Pancakeswap,链接:https://pancakeswap.finance/

 

如果你在币安智能链上使用 Pancakeswap,你可以阅读以下的指南,了解如何在 Pancakeswap V2 或 V3 中添加流动性(如果你在 Pancakeswap 中没有看到 V2 选项,可以选择使用 V3)

 

 

 

 

 

下面我们将讨论如何在以太坊主网的 Uniswap 中 添加流动性

 

在这里,我们以 Uniswap(在以太坊主网) 为例。 

 

1.前往 Uniswap 网站:https://app.uniswap.org/#/swap

 

 

2.点击池子POOL

 




 

 

 

 

3.点击(更多)MORE,然后点击 V2 流动性(V2 LIQUIDITY)

 




 

 

 

 

4. 点击创建 (Create a pair)

 




 

 

 

 

5. 点击 选择代币 Select a token

 



 

 

 

 

 

 

6.将合约地址复制并粘贴到空白处,等待您的代币出现

 




 

 

 

 

7. 然后点击你的代币

 




 

 

 

 

8. 点击 明白(I understand)

 




 

 

 

 

9. 选择您的 eth 输入和代币输入。例如,如果您想用 2 eth 列出 100 个代币,那么您的初始代币价格将为每个代币 0.02 eth。之后,单击批准 Approve

 




 

 

 

 

 

10. 点击供应Supply并确认交易,您的代币将在 Uniswap 上币。*关于发币时间,一旦你点击了供应Supply 并确认交易,你的代币就会几秒钟内上到Uniswap。如果早些已经决定了上币的时间,要自行拿捏时机来发币。

 




 

 

 

 

恭喜,您的代币现已列在 Uniswap 中。您可以开始您的代币项目和活动,寻找更多的投资者来投资您的代币。

 

如果您使用 BSC(币安智能链),请使用 Pancakeswap,链接:https://pancakeswap.finance/

 

如果你在币安智能链上使用 Pancakeswap,你可以阅读以下的指南,了解如何在 Pancakeswap V2 或 V3 中添加流动性(如果你在 Pancakeswap 中没有看到 V2 选项,可以选择使用 V3)

 

 

 

 

我们将在下方详细解释如何使用这个普通迷因智能合约代币的放弃权限&拥有权的功能来放弃权限&拥有权。



*重要步骤# 1


智能合约代币的权限&拥有权放弃的原因是通过放弃(弃权)智能合约和代币的所有权来增加投资者和交易者对代币的可信度和认可,从而禁止智能合约和代币的所有者使用智能合约和代币的特定其他功能。

 

让我们开始我们的第一步。

 

1.现在回到 Remix IDE,点击如下所示的小三角箭头。

























2. 点击renounceOwn按钮并确认metamask 的跳出窗口的交易




恭喜你,智能合约和代币的所有权现已放弃!

 

 

*放弃代币所有权后,你将无法使用代币的某些功能,但不会影响代币的流动性。

 

 

*一旦你放弃对代币的所有权,你将无法再次赎回所有权,因为交易是不可逆转的,并且无法再次赎回代币的所有权。

 

 

*你可以随时放弃你的代币的所有权。它不会影响代币的任何流动性,你可以在增加流动性之前或之后选择放弃代币的所有权。

 

 

*由于放弃你的代币所有权不会影响代币的流动性,因此你在放弃所有权后仍然可以自由地添加和删除流动性。

 




*重要步骤# 2


如果你不小心,或者把remix ide关掉了,那么该如何 放弃代币权限&拥有权 呢?

 

 

不必担心,跟着下面的步骤就行了。

 

 

1.回到狐狸钱包,点击活动,点击 Contract Deployment (合约部署), 然后点击 浏览

















2.点击 合约地址





3.在这个页面,点击 合约 Contract。







4.点击 编写合约 Write Contract





5.点击 红色圆圈 旁边的 连接按钮 Connect to Web3 以 连接 狐狸钱包。







6. 点击上方小狐狸插件 以 检查 确保 狐狸钱包地址 正确连接。一定要确定连接的钱包地址的是 发行代币 的 钱包地址。






7.点击 "renounceOwnership" 按钮。 





8.点击 Write 然后确认交易以放弃所有权。一定要确定连接的钱包地址的是 发行代币 的 钱包地址。




恭喜你,智能合约和代币的所有权现已放弃!

 

 

*放弃代币所有权后,你将无法使用代币的某些功能,但不会影响代币的流动性。

 

 

*一旦你放弃对代币的所有权,你将无法再次赎回所有权,因为交易是不可逆转的,并且无法再次赎回代币的所有权。

 

 

*你可以随时放弃你的代币的所有权。它不会影响代币的任何流动性,你可以在增加流动性之前或之后选择放弃代币的所有权。

 

 

*由于放弃你的代币所有权不会影响代币的流动性,因此你在放弃所有权后仍然可以自由地添加和删除流动性。

 

 

 

请记住,这是一个普通代币(不是貔貅代币),投机客和投资者可以自由买卖你的代币。

 

 

*请记住,这篇文章仅用于测试和教育目的,基于这是个普通代币的智能合约教程,您可以使用此方法创建自己的代币。

 

 

如果我想取回我的 ETH 和代币怎么办?该怎么办?

 

哦,很简单,让我们进入下一个步骤:去除流动性 REMOVE LIQUIDITY

 

 

如果你使用以太坊主网,请使用 Uniswap,链接:https://app.uniswap.org/#/swap

 

如果您使用 BSC(币安智能链),请使用 Pancakeswap,链接:https://pancakeswap.finance/

 

如果你在币安智能链上使用 Pancakeswap,你可以阅读以下的指南,了解如何在 Pancakeswap V2 或 V3 中添加流动性(如果你在 Pancakeswap 中没有看到 V2 选项,可以选择使用 V3)

 

 

 

 

在本章中,我们将使用 Uniswap(以太坊主网)作为我们的一个简单的例子。

 

1.如果你想取回eth,点击池子liquid pool,你会看到你创建的代币/ETH,然后点击移除remove




2.如果你想全部撤回,选择全部 max,点击批准Approve,点击移除Remove,你会拿回你的代币和 ETH




今天的 可放弃权限&拥有权的安全自由买卖普通迷因代币 合约教程 就到这里。当然,这还没有结束,您可以通过多种方式和技巧来使用此发币技术,以最大限度地发挥效果。

 

 

我们将在下一篇文章中讨论更多关于代币技巧和技术的内容。 祝你发币愉快! 

 

 

马上复制可放弃权限&拥有权的安全自由买卖普通迷因代币智能合约代码: https://www.createyourowntoken.net/zh/copy-of-supply-printing-normal-meme-t

 

 


 


 


 




普通代币智能合约教学指南系列:

 

 

 

 

 

 

 

 


 


 还想要些别的?

 

 

貔貅币智能合约教学指南系列:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

有任何疑问吗?

 

 

通过电报联系我:https://t.me/devswanson

 

 

 

 

马上复制复制可放弃权限&拥有权的安全自由买卖普通迷因代币智能合约代码: https://www.createyourowntoken.net/zh/copy-of-supply-printing-normal-meme-t

 




*******

# 任何未经授权的代码编辑与更改都可能导致合约部署失败


合约代码如下: ---


pragma solidity 0.5.16; interface IBEP20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8); /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the token name. */ function name() external view returns (string memory); /** * @dev Returns the bep token owner. */ function getOwner() external view returns (address); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address _owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot 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-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ 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; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract DevToken is Context, IBEP20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; uint8 private _decimals; string private _symbol; string private _name; constructor() public { _name = "DevToken"; _symbol = "DVET"; _decimals = 18; _totalSupply = 1000000000000000000000000; _balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } /** * @dev Returns the bep token owner. */ function getOwner() external view returns (address) { return owner(); } /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8) { return _decimals; } /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory) { return _symbol; } /** * @dev Returns the token name. */ function name() external view returns (string memory) { return _name; } /** * @dev See {BEP20-totalSupply}. */ function totalSupply() external view returns (uint256) { return _totalSupply; } /** * @dev See {BEP20-balanceOf}. */ function balanceOf(address account) external view returns (uint256) { return _balances[account]; } /** * @dev See {BEP20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) external returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {BEP20-allowance}. */ function allowance(address owner, address spender) external view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {BEP20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) external returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {BEP20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {BEP20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "BEP20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {BEP20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {BEP20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "BEP20: decreased allowance below zero")); return true; } /** * @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing * the total supply. * * Requirements * * - `msg.sender` must be the token owner */ /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "BEP20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "BEP20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "BEP20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "BEP20: approve from the zero address"); require(spender != address(0), "BEP20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "BEP20: burn amount exceeds allowance")); } }


334 次查看

Comments


bottom of page