Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using version 1.0.0-beta.24, account not being created #1154

Closed
kaizenx opened this issue Nov 2, 2017 · 9 comments
Closed

Using version 1.0.0-beta.24, account not being created #1154

kaizenx opened this issue Nov 2, 2017 · 9 comments
Assignees
Labels
Documentation Relates to project wiki or documentation

Comments

@kaizenx
Copy link

kaizenx commented Nov 2, 2017

Calling this command
var Web3 = require('web3');
var host = '';
var net = require('net');
var web3 = new Web3(new Web3.providers.IpcProvider(host, net));
var account = web3.eth.accounts.create(web3.utils.randomHex(32));

will give a result like this

{ address: '0x27DC662FE77BCD3c8D083bA5a6FD047eAC3885D1',
privateKey: '0x9deab8fb8b8a58fd9fa59757fc2062ed0f43657d574e3af72d4131636f46738d',
signTransaction: [Function: signTransaction],
sign: [Function: sign],
encrypt: [Function: encrypt] }

But when I run web3.eth.getAccounts, it does not display the new account.

I also checked by attaching Mist to the local dev node, also not showing the new account.

Going through web3-ipc and using newAccount is fine.

Is it creating them but not saving them?

@amitsharma8891
Copy link

amitsharma8891 commented Nov 2, 2017

Try to create a personal account.

@kaizenx
Copy link
Author

kaizenx commented Nov 3, 2017

The personal account creation works.

I'd like to know why this doesn't work yet.

If it is in the docs, it should work, else it is a bug.

@monokh
Copy link

monokh commented Nov 4, 2017

I think the docs are clear about this. When you create an account with web3.eth.accounts.create, web3 only generates and returns an account for you to use locally with utility functions for signing transactions under account.signTransaction etc. You can also create accounts locally in the wallet structure. It is effectively just a utility for account management.

web3.eth.getAccounts just makes an RPC call for eth_accounts which would return the accounts that the provider (metamask, geth etc.) have unlocked.. It doesn't interact with the local accounts.

It would be an idea to allow the web3.eth methods to use the wallets under web3.eth.accounts.wallets but that would be up to the maintainers if this would be desirable. I imagine the initial thinking is to keep web3.eth.accounts as a standalone module.

@kaizenx
Copy link
Author

kaizenx commented Nov 6, 2017

Ah ok, that makes sense if it is meant to be a utility module.

@connectdotz
Copy link

why distinguish local accounts vs remote accounts? Does it make sense for them to co-exist in a given application? Just filed a related issue (#1204)... judging the sendRequest is intercepting/routing eth_sign and eth_sendTransaction to eth.accounts, the eth.accounts didn't seem to be merely a utility class... IMHO, the fact the remote and local accounts can coexist and behave differently for different API is a serious bug...

@CryptoKiddies
Copy link

@monokh @frozeman there is conflicting information here: https://web3js.readthedocs.io/en/1.0/web3-eth.html#sign

The doc on web3.eth.sign says "The 2. address parameter can also be an address or index from the web3.eth.accounts.wallet. It will then sign locally using the private key of this account."

However this would override the personal wallet object. When both a personal wallet and account wallet exist, does/should the index point always point at the local wallet? I have been placing the address in the from parameter to avoid serious confusion. Some clarity on the web3 wallets organization would be very helpful, as developers start to design more complicated schemes that involve mixed account utilities.

@nivida nivida self-assigned this Aug 9, 2018
@nivida nivida added the Documentation Relates to project wiki or documentation label Aug 9, 2018
@lutianzhou001
Copy link

Ah ok, that makes sense if it is meant to be a utility module.

I met the same problem ,have u solved it yet?

@tcrowe
Copy link

tcrowe commented Dec 14, 2018

If you're available to comment can you see if this PR is successful at clarifying the docs surrounding getAccounts, newAccount, and accounts.create()? 👍🏻👎🏻 Please and thank you 🤗

@nivida
Copy link
Contributor

nivida commented Apr 2, 2019

This will get improved with the PR #2631. I will update the documentation.

@nivida nivida closed this as completed Apr 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Relates to project wiki or documentation
Projects
None yet
Development

No branches or pull requests

8 participants