0

I have deployed on testrpc contract with ERC20 token which has following constructor:

pragma solidity ^0.4.4;
import 'zeppelin-solidity/contracts/token/StandardToken.sol';

contract TutorialToken is StandardToken {
    string public name = 'TutorialToken';
    string public symbol = 'TT';
    uint public decimals = 2;
    uint public INITIAL_SUPPLY = 12000;

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

My understanding is that contract will be deployed by 0th testrpc account. However when I do

TutorialToken.deployed().then(c => c.balanceOf('<0th account addr>').then(b => console.log(b)))

It displays

{ [String: '0'] s: 1, e: 0, c: [ 0 ] }

So it seems that the account has no balance. I aslo can't see the balance in "Token" tab of metamask. Looks like some other address was used to create account. However I'm not able to find any function to see who is contract creator (who was msg.sender).

Is it possible in truffle console to see who is a contract creator?

Update

The problem with balance was because of the typo: constructor name was TotorialToken instead of TutorialToken.

The original question still holds though: how to print contract owner?

Update #2

To actually see contract owner I can do something like this (thanks pabloruiz55 for suggestion):

address owner;

function TutorialToken() {
    owner = msg.sender;
    ...
}

That works. So I guess my question is different then: does OpenZeppelin's StandardToken contains owner field which can be accessed?

1

The easiest way would be to store the owner/creator of the contract in a state variable on deployment.

pragma solidity ^0.4.8;
contract myContract  {

    address public owner;

    function myContract() {
        owner = msg.sender;
    }
}
  • Thanks for the suggestion. I found out that my question is a little bit different, updated the question. – yname Oct 7 '17 at 16:33
1

Inspection of StandardToken shown following inheritance hierarchy:

  ERC20Basic
   /      \
ERC20  BasicToken
   \      /
 StandardToken

With following fields in each contract:

StandardToken:
    mapping (address => mapping (address => uint256)) allowed

ERC20:
    none

BasicToken: 
    mapping(address => uint256) balances

ERC20Basic:
    uint totalSupply

In order to have owner property contract should extend Ownable contract (thanks Ismael for the tip):

contract TutorialToken is StandardToken, Ownable {
   ...
}
  • 1
    But it should be possible, add import 'zeppelin-solidity/contracts/ownership/Ownable.sol' to the top of the file, and then add Ownable to the class inheritance contract TutorialToken is StandardToken, Ownable {. – Ismael Oct 8 '17 at 17:47
1

This worked from me from the development console:

x = TutorialToken.deployed() x.then( i => i.owner().then(console.log))

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.