1

I am playing around with my ERC20 token. I created token on Rinkeby test network. I can't understand where I did a mistake. I am interacting with my token in truffle console.

After command

Token.deployed().then(function(instance){app = instance;})

I check my balance with command:

app.balanceOf.call("0xb9ac6f47A43d24F9D0d37049b7dbdC4EA0083d37")

And it works fine, I am getting the right answer.

Then I am trying to check my balance with commands:

app.balanceOf.call(accounts[0], {from: accounts[0]})

or

app.balanceOf.call(app.accounts[0], {from: app.accounts[0]})

or

app.balanceOf.call(address)

Where I did a mistake? How to call a function balanceOf ?

Information after command app:

 balanceOf:
  { [Function: bound ]
    request: [Function: bound ],
    call: [Function: bound ],
    sendTransaction: [Function: bound ],
    estimateGas: [Function: bound ],
    getData: [Function: bound ],
    address: [Circular] },


....


 balanceOf:
  { [Function]
    call: [Function],
    sendTransaction: [Function],
    request: [Function: bound ],
    estimateGas: [Function] },
1

You can do:

app.balanceOf(accounts[0])

if you use call the function is evaluated locally (in the node you are connected) and the transaction is not sent to the network, therefore no need for {from: accounts[0]}.

  • Comments are not for extended discussion; this conversation has been moved to chat. – eth May 8 '18 at 23:24

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.