November 2018
Intermediate to advanced
528 pages
13h 21m
English
Having added the code to support delegated transfers, we now have a complete implementation of our ERC-20 token:
pragma solidity ^0.4.24; contract PacktToken { string public name = 'Packt ERC20 Token'; string public symbol = 'PET'; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); constructor(uint256 _initialSupply) public { balanceOf[msg.sender] = _initialSupply; totalSupply = _initialSupply; emit Transfer(address(0), msg.sender, totalSupply); } function transfer(address ...Read now
Unlock full access