1

Compiling is failing.

vi contracts/MyCoin.sol:

pragma solidity ^0.4.18;

import 'zeppelin-solidity/contracts/token/ERC20/StandardToken.sol';

contract MyCoin is StandardToken {
  string public name = "MyCoin";
  string public symbol = "MC";
  uint public decimals = 2;
  uint public INITIAL_SUPPLY = 10000 * (10 ** decimals);

  function MyCoin() public {
    totalSupply = INITIAL_SUPPLY;
    balances[msg.sender] = INITIAL_SUPPLY;
  }
}

When I run truffle compile:

➜  my-coin truffle compile  
Compiling ./contracts/MyCoin.sol...
Compiling zeppelin-solidity/contracts/math/SafeMath.sol...
Compiling zeppelin-solidity/contracts/token/ERC20/BasicToken.sol...
Compiling zeppelin-solidity/contracts/token/ERC20/ERC20.sol...
Compiling zeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol...
Compiling zeppelin-solidity/contracts/token/ERC20/StandardToken.sol...

/Users/pedro/src/my-coin/contracts/MyCoin.sol:13:5: TypeError: No matching declaration found after variable lookup.
    totalSupply = INITIAL_SUPPLY;
    ^---------^
Compilation failed. See above.

2 Answers 2

4

OZ has updated their code besides restructuring some of the folders.

Old Answer (pre 2.X.X release)

Look here: https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/ERC20/BasicToken.sol

Your direct answer: totalSupply_ (the underscore) is the variable name you're looking for.

Current Answer Update (12/11/18):

uint256 private _totalSupply;

/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
    return _totalSupply;
}

New Link: https://github.com/OpenZeppelin/openzeppelin-solidity/blob/v2.0.0/contracts/token/ERC20/ERC20.sol

OZ has refactored their repo ever since v2.X.X release

1
1

Total supply variable is defined as a function. Modify your code

pragma solidity ^0.4.18;

import 'zeppelin-solidity/contracts/token/ERC20/StandardToken.sol';

contract MyCoin is StandardToken {
  string public name = "MyCoin";
  string public symbol = "MC";
  uint public decimals = 2;
  uint public INITIAL_SUPPLY = 10000 * (10 ** decimals);

  function MyCoin() public {
    totalSupply_ = INITIAL_SUPPLY;
    balances[msg.sender] = INITIAL_SUPPLY;
  }
}

Your Answer

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

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