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

Best way to transfer accounts between providers? #1501

Closed
RobTS opened this issue Mar 27, 2018 · 3 comments
Closed

Best way to transfer accounts between providers? #1501

RobTS opened this issue Mar 27, 2018 · 3 comments
Assignees

Comments

@RobTS
Copy link

RobTS commented Mar 27, 2018

I am currently building a project with Web3.js on Quorum.

So far, the accounts you can use for transactions are seemingly coupled to the connection/provider you connect to, with no way to extract and import the private key back into another connection, if I am not mistaken.

With web3 1.0, there also seems to be the possibility of importing accounts from a private key and adding them to the wallet, like so:

const acc = web3.eth.accounts.privateKeyToAccount('c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3');
web3.eth.accounts.wallet.add(acc);

But then, there seems to be no way to add it to the personal "keychain" (web3.eth.personal) and use the unlock functionality. And as far as I can tell, I can not deploy a contract/do a transaction with these accounts, at least not on Quorum.

Why can't normally generated accounts be imported/exported? Isn't this a bad idea considering the provider they are coupled to can go down at any point in time?
And is the current form of importing accounts creating second-class citizen, am I missing an important command here or is this a Quorum-exclusive problem?

@nivida nivida self-assigned this Aug 9, 2018
@abhinav2196
Copy link

I am facing the same problem but read somewhere that if we want to use it same way to simply call contract functions even if they're state changing, you have to sign each transaction before sending it with your private key. Allthough may be my node code is having some problem, I find the concept valid. I'm also looking or a way to add private key to our keychain and then start transacting simply.

@Flash-Git
Copy link
Contributor

That's a cute honeypot. I believe those accounts are stored with the Geth node, so it makes sense for them to be attached to the provider. web3.eth.personal doesn't mention the ability to import/export accounts to/from this personal account list.

However, as described under web3.eth.accounts, you can use web3.eth.accounts.wallet.add(account);, (where "account" is what you get with web3.eth.accounts.privateKeyToAccount(private key);) to form an in memory wallet that should be able to do everything you would do with the usual accounts, I don't believe they require unlocking.

If you want to re-use a wallet of accounts, you could encrypt them with web3.eth.accounts.wallet.encrypt(password); and then save them with web3.eth.accounts.wallet.save(password [, keyName]); for in browser storage.

If you are having issues with this wallet not functioning as expected, I am happy to help but I'll need some more information.

@nivida
Copy link
Contributor

nivida commented Apr 16, 2019

Closed because of the ongoing clean up of the issue list. Feel free to ask this in our gitter channel or on stackoverflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants