Ok, I am pretty new to developing contracts, and I did so by using dAPP and truffle. But when adding it to the chain, it says there is no balance to the contract. How can I add tokens to be bought? https://etherscan.io/address/0x8f8a3c51b1eaaefe9052fc86cff57971b11dde45


When a contract is created, the constructor function is called to initiate the contract.

Here is the constructor function for your contract:

constructor (uint256 _initialSupply) public {
    balanceOf[msg.sender] = _initialSupply;
    totalSupply = _initialSupply;

You can see that this constructor function expects an input of _initiatalSupply to define the initial token balance of the contract.

You will need to create a new contract, and make sure to send in a value to be used during contract creation for the constructor function.

  • I forgot to add this line: uint256 _totalSupply = 100000000; is that correct? Aug 4 '18 at 18:23
  • @ArnfinnIngebrigtsen No. When you created the contract, you should have supplied the number of tokens you wanted to create to the constructor.
    – natewelch_
    Aug 4 '18 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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