0

As my Question title states, I would like to know, If it's a requirement to run my own hosted Geth Node synched with the Main-Network in order to use web3.js (localhost Node?) to create accounts?

Or is it possible to "point" web3 with the Main Network as a provider? and with this reference, create accounts for example?

If the latter is possible, Could you please show me an example?

-Kind Regards,

1

Creating accounts is just picking a large random number. It can certainly be done offline and without a node to connect to.

E.g., using ethereumjs-wallet:

> const key = require('ethereumjs-wallet').generate();
undefined
> key.getAddress().toString('hex')
'eac913b60f61e566910b02c7bf6fd47ef115875c'
> key.getPrivateKey().toString('hex')
'62e1499a16be79fcd87e0fa748a6735a12e7252568942a8226179c02d5a454ac'
  • Interesting, May I ask a follow up question? How then, do you "integrate" that Account into the Main-Net? – jlstr Jan 3 '18 at 0:24
  • 1
    A simplified view of Ethereum is that it's a distributed mapping of addresses to balances. (E.g. "0x123 owns 3 ether," "0x987 owns 1 ether," etc.) Anything not in the map owns 0 ether. So the account I just created above has 0 ether. If you send it 1 ether, it will have 1 ether, even though I've never done anything with the account. So there's no explicit "creation" step that involves the network. You'll need to talk to the network only when you need to make a transaction (using your account's private key). – user19510 Jan 3 '18 at 0:29
  • Awesome! That's a fantastic lesson, Thank you. May I point out however, that what I need to know the most is How to use web3 with the Main-Network as a Provider, Do you happen to know how to do that? (As I'd prefer NOT to run my own Node). – jlstr Jan 3 '18 at 0:36
  • 1
    Yes, you can use any public node. The most popular is Infura.io, and even more popular is using that via MetaMask. (It's the default in MetaMask.) Perhaps this blog post of mine will help: programtheblockchain.com/posts/2017/12/13/… – user19510 Jan 3 '18 at 0:38
  • 1
    To use an account, you just need the private key. Most tools (MetaMask, Geth, Mist) encrypt the private key with a password, but it doesn't have to work that way. I'm not sure I can give more info without understanding the scenario better; sorry! – user19510 Jan 3 '18 at 0:48

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.