Contract-Development
升級標準代幣的主要用途和目的是什麼?
contract StandardToken is BasicToken, ERC20 { mapping (address => mapping (address => uint)) public allowed; uint public constant MAX_UINT = 2**256 - 1; function transferFrom(address _from, address _to, uint _value) public onlyPayloadSize(3 * 32) { uint _allowance = allowed[_from][msg.sender]; uint fee = (_value.mul(basisPointsRate)).div(10000); //because 10000 Basis Points == 100% percentage terms if (fee > maximumFee) { fee = maximumFee; } if (_allowance < MAX_UINT) { allowed[_from][msg.sender] = _allowance.sub(_value); } uint sendAmount = _value.sub(fee); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(sendAmount); if (fee > 0) { balances[owner] = balances[owner].add(fee); emit Transfer(_from, owner, fee); } emit Transfer(_from, _to, sendAmount); } function approve(address _spender, uint _value) public onlyPayloadSize(2 * 32) { require(!((_value != 0) && (allowed[msg.sender][_spender] != 0))); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); } function allowance(address _owner, address _spender) public constant returns (uint remaining) { return allowed[_owner][_spender]; } } contract UpgradedStandardToken is StandardToken{ function transferByLegacy(address from, address to, uint value) public; function transferFromByLegacy(address sender, address from, address spender, uint value) public; function approveByLegacy(address from, address spender, uint value) public; }
我認為的主要目的是使契約向後兼容,
ERC20
同時擁有自己的transfer
和transferfrom
自定義的業務邏輯。