I have setup a latest single node geth for my learning. I am also using truffle-hd-wallet in my app. While in my app i do not get the correct coinbase account on using 'web3.eth.getCoinbase()'; the same command in the geth cli gives me correct coinbase account.

In my app 'web3.eth.getCoinbase()' retunrs me the first account created by truffle-hd-wallet.

1 Answer 1


When you use truffle-hdwallet-provider, it sets coinbase to first account of HD wallet. thats why you get different results.

You can view code here: https://github.com/trufflesuite/truffle-hdwallet-provider/blob/master/index.js

 Line 5: var HookedSubprovider = require('web3-provider-engine/subproviders/hooked-wallet.js');

 Line 28: this.engine.addProvider(new HookedSubprovider({
 Line 29:   getAccounts: function(cb) { cb(null, tmp_accounts) },

And, https://github.com/MetaMask/provider-engine/blob/master/subproviders/hooked-wallet.js

Line 92: case 'eth_coinbase':
Line 93:       // process normally
Line 94:       self.getAccounts(function(err, accounts){
Line 95:         if (err) return end(err)
Line 96:         let result = accounts[0] || null
Line 97:         end(null, result)
Line 98:       })
  • thanks. Is there a wallet that can also manage accounts created in the geth node along with external ones?
    – karts
    Commented Jun 18, 2018 at 1:28
  • why would you want that? Concept of coinbase account is used primarily when you are mining, the mining rewards always goes to coinbase account.
    – kherwa
    Commented Jun 18, 2018 at 1:38
  • no specific usecase..but is it not good a single wallet manages all the accounts?
    – karts
    Commented Jun 18, 2018 at 1:55
  • yes, thats what is happening here, hd wallet is only managing accounts in its hd path, not the local geth accounts.
    – kherwa
    Commented Jun 18, 2018 at 2:38

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.