第22篇 ERC20智能合约(0.6.0)

本文给出 0.6.0 版本的标准ERC20智能合约(源码来自),供大家参考。

1.标准ERC20合约源码:

该部分由4部分组成;

1.1 SafeMath.sol

主要处理算术运算中的溢出问题,达到更安全的计算目的;使用该库可以消除没有检测的计算类错误;因此建议始终使用它;

// SPDX-License-Identifier: MITpragma solidity ^0.6.0;/*** @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 operati

第22篇 ERC20智能合约(0.6.0)

本文给出 0.6.0 版本的标准ERC20智能合约(源码来自),供大家参考。

1.标准ERC20合约源码:

该部分由4部分组成;

1.1 SafeMath.sol

主要处理算术运算中的溢出问题,达到更安全的计算目的;使用该库可以消除没有检测的计算类错误;因此建议始终使用它;

// SPDX-License-Identifier: MITpragma solidity ^0.6.0;/*** @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 operati