1

:) I am new to Ethereum technology. I am studying the web3js JavaScript library from the official documentation and I don't understand the web3.eth.defaultAccount. What is this for? Why I have to use it in my web application? For example, this code:

web3Istance.eth.defaultAccount = web3Istance.eth.accounts[0];

I am using testrpc for testing my Dapp locally. So in this case I set the first account to be the default one. But why I do have to set the default account?

1 Answer 1

3

defaultAccount is used as the default from field when you send a transaction. That is, if you send a transaction and do not specify the from field, the value of web3.eth.defaultAccount will be used, if previously set. In case of no from as well as no defaultAccount, an error occurs.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.