在了解以太坊智能合约短地址攻击之前,先要简单了解一下以太坊代币ERC-20 TOKEN 的一些基础知识。ERC(EthereumRequest for Comment)即以太坊通用征求意见协议,开发者可以通过提交EIP(Ethereum Improvement Proposal以太坊改进建议),向以太坊社区提交新的ERC标准提案。ERC-20是整个加密社区中的所有标准中名气最大的,而且大多数基于以太坊平台发布的token都基于ERC-20协议。ERC-20 TOKEN标准中,提供了一些基础函数,如下:
// Abstract contract for the full ERC 20 Token standard
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
pragma solidity ^0.4.21;
contract EIP20Interface {
/* This is a slight change to the ERC20 base standard.
function totalSupply() constant returns (uint256 supply);
is replaced with:
uint256 public totalSupply;
This automatically creates a getter function for the totalSupply.
This is moved to the base contract since public getter functions are not
currently recognised as an implementation of the matching abstract
function by the compiler.
*/
/// total amount of tokens
uint256 publi