0

In my previous post I got answer but still I need some clarifications let say when deploying contract with node js we have this line

 try {
    web3.personal.unlockAccount(web3.eth.coinbase, password);
} catch(e) {
    console.log(e);
    return;
}

which is unlocking account to make transaction for contract creation .

What if account is created with this way

web3.eth.accounts.create([entropy]);

And I have private key encyrpted somewhere on the system how I shall use it to unlock (or jsut use account) account let say after a week from it's creation ?

Also can u give details on what does entropy do ?

Is it like password in case of personal account ?

Thanks and sorry if questions are similar , there are not much resources to get more detailed info

0

Having a private key you can create a new account with web3.eth.accounts.wallet.add(account|privateKey)

You can use your account normally after.

// Create account
var account = web3.eth.accounts.create([entropy]);

// Load account
web3.eth.accounts.wallet.add(account)

// Set the account as the default
web3.eth.defaultAccount = account.address;

// Use it normally
web3.eth.signTransaction(transactionObject, address [, callback])

In the transactionObject you can omit the from parameter and the default account will be used.

Make sure to read the documentation

  • That is not he answer to my question . ? I know about personal and tx , please read question again . – Hrach Karapetyan Apr 9 '18 at 5:57
  • Correct typos and rephrase to make it more clear. Ask less questions. I will read your question after – cleanunicorn Apr 9 '18 at 9:54
  • Sure I will rephrase the question – Hrach Karapetyan Apr 9 '18 at 12:47
  • if you import a geth V3 wallet to web3, how do you make it the default address? I can't get web3 to successfully sign txns when using web3.eth.accounts.wallet.decrypt. I try to set web3.eth.accounts.wallet[0]['address'] to default after decrypting. Thanks a bunch. – GViz Jun 1 '18 at 1:10
  • I think I should be using web3.eth.accounts.decrypt perhaps instead of the wallet methods, but there's no clear explanation on this. – GViz Jun 1 '18 at 1:21

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.