How do I modify this so that all created tokens go to Owner (the one who receives funds to the Beneficiary address). I assume this contract is one requiring change.

contract ERC20Basic {

  uint256 public totalSupply;
  function balanceOf(address who) public view returns (uint256);
  function transfer(address to, uint256 value) public returns (bool);
  event Transfer(address indexed from, address indexed to, uint256 value);

  • This isn't the actual code of a contract. It's just an interface (function declarations).
    – user19510
    Commented Dec 28, 2017 at 12:39

1 Answer 1


What you posted above is just an interface, not the actual token contract. Having said so, you typically want to assign all tokens when deploying the token contract. You should add a constructor function like so:

function ERC20Basic() public {
    totalSupply = 100000 * 10 ** uint(decimals); //Change to whatever initial supply you want
    balances[msg.sender] = totalSupply;

That will assign all the tokens to the account deploying the contract.

  • How about this. Same? uint256 constant INITIAL_SUPPLY = xxx* 10**18; function TESTCOIN () public { balances[msg.sender] = INITIAL_SUPPLY;
    – user25297
    Commented Dec 30, 2017 at 21:21
  • You are not setting the totalSupply, which is very important. TotalSupply should always match the sum of all balances. Commented Dec 30, 2017 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.