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
  • What is the error your getting... ? Update your qus. Commented May 7, 2018 at 6:12

1 Answer 1

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]}.

2
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – eth
    Commented May 8, 2018 at 23:24
  • just for curious, would app.balanceOf be encoded as a call in the EVM bytecode? Commented Aug 8, 2019 at 11:53

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.