本文给出0.4.24版本的标准ERC20智能合约(标准请大家自行搜索),供大家参考。
1.标准ERC20合约源码:
pragma solidity ^0.4.24;
library SafeMath {
/**
* @dev Multiplies two numbers, 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);
return c;
}
/**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*/
function div(uint256 a, uint256 b)
本文介绍了0.4.24版本的ERC20智能合约,包括SafeMath库用于安全计算,IERC20接口定义标准,构造函数设置初始参数,balanceOf、transfer、approve和transferFrom等核心功能,以及冻结账号和token自主释放的附加功能。合约已在Remix测试并可部署。
订阅专栏 解锁全文
1486

被折叠的 条评论
为什么被折叠?



