2

Let's say I've created an account using this code as explained in docs:

web3.eth.accounts.create();
> {
    address: "0xb8CE9ab6943e0eCED004cDe8e3bBed6568B2Fa01",
    privateKey: "0x348ce564d427a3311b6536bbcff9390d69395b06ed6c486954e971d960fe8709",
    signTransaction: function(tx){...},
    sign: function(data){...},
    encrypt: function(password){...}
}

How do I connect (unlock) to that account later and see all the ETH and other tokens it contains?

3

To get the Ether Balance use web3.fromWei(eth.getBalance(acct), "ether")

The following links might give a guide on checking token balance.

http://nuclearcryptobuddha.blog/2017/06/how-to-send-receive-and-check-balance-of-erc20-tokens-using-geth/

https://lightrains.com/blogs/useful-ethereum-geth-javascript-snippets

How do I print my account balances and TheDAO tokens from geth

I haven't actually tried it.

  • Thank you for your help. A few things aren't clear to me yet. 1) Once I create an account I get a private key and an encryption method. Should I use the encrypt method on the spot and save its result to use later? 2) when I unlock the account, you mentioned a password, but what about the private key? 3) how do I connect the two commands you wrote together? Does personal.unlockAccount return an 'eth' object? – Alon Nov 8 '17 at 16:55
  • you have to store the key in local storage encrypted using a password and decrypt with the password when needed to sign a transaction. here web3js.readthedocs.io/en/1.0/… to sign a transaction you need only the private key and no password. You use the password to store the private key in secure. as doc says >privateKey - string:This should never be shared or stored unencrypted in localstorage! – Achala Dissanayake Nov 8 '17 at 17:37
  • unlocking an account means getting the private key to sign data or transactions . – Achala Dissanayake Nov 8 '17 at 17:43
  • Not yet, I cannot test it yet since I'm stuck in an earlier step, as you can see here: ethereum.stackexchange.com/questions/30245/… – Alon Nov 9 '17 at 8:00
  • 1
    I've deleted this question because I solved it by myself. Now I face with another problem, I will test your code as soon as I get my program run at all. – Alon Nov 9 '17 at 19:20

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.