2

From this, i found that

To add a token to watch, go to the contracts page and then click "Watch Token". A pop-up will appear and you only need to paste the contract address. The token name, symbol and decimal number should be automatically filled.

How can i perform same thing in case of testnet. I mean how will a testnet user will see the tokens he possess.I am using GETH client and web3 to interact with node and pass related data to UI .

Aniket
  • 3,545
  • 2
  • 20
  • 42

1 Answers1

1

From your question, you don't want to use the Ethereum Wallet to add the Watch Token function. Instead you want to use geth JavaScript to find the token balance.

If this is the case, you can use the same type of script as in Script To Get Account Balances And Including TheDAO Tokens.

Your code would look like the following:

var tokenContractABI = {your token contract ABI};
var tokenContractAddress = "{your token contract address}";
var tokenContract = eth.contract(tokenContractABI).at(tokenContractAddress);
var tokens = tokenContract.balanceOf({user address});
console.log(tokens);
BokkyPooBah
  • 40,274
  • 14
  • 123
  • 193
  • Here : https://www.ethereum.org/token, they provide an UI page to execute the token contract but in geth private blockchain , we use eth.getbalance(address) to see the balance.It just shows ether. So how can user check the tokens like that? – Aniket Aug 23 '16 at 08:09
  • What operating system are you running? The reason why I'm asking is because you can run geth on a private network and connect the Ethereum Wallet to geth and EW will be your UI. See the answer to http://ethereum.stackexchange.com/questions/5716/ethereum-wallet-with-private-testnet-not-working-chaindata-lockpermission-deni . – BokkyPooBah Aug 23 '16 at 08:24
  • I saw your message about Windows, but it has disappeared. Check out http://ethereum.stackexchange.com/a/4421/1268 . Message back if it does not work. – BokkyPooBah Aug 25 '16 at 07:22
  • yeah, i saw the same after comment and then i deleted comment. I am trying to solve my purpose. In case of problem, i will be back to you.:) – Aniket Aug 25 '16 at 07:26
  • @BookyPooBah I connected node with ethereum wallet. I have two accounts. Wallet is showing the balance of account2 but account1 which is etherbase is showing 0 balance. I can see the balance in account1 by geth cli.what to do? – Aniket Aug 25 '16 at 07:56
  • In your WIndows Task Manager, check you are not running two instances of geth. You should be starting the first geth instance with the appropriate parameters, then run Ethereum Wallet. If your geth parameters are correct, Ethereum Wallet will connect to the geth instance you started. If not, Ethereum Wallet will try to start up a second geth instance. – BokkyPooBah Aug 25 '16 at 14:39
  • 1
    I am running one geth instance in which i have created two accounts.I don't know what was the problem. I closed the geth instance and ran again now it is working fine.Thanks. – Aniket Aug 26 '16 at 06:34