Closed kaizenx closed 5 years ago
Try to create a personal account.
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.
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.
Ah ok, that makes sense if it is meant to be a utility module.
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...
@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.
Ah ok, that makes sense if it is meant to be a utility module.
I met the same problem ,have u solved it yet?
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 🤗
This will get improved with the PR https://github.com/ethereum/web3.js/pull/2631. I will update the documentation.
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?