2

Basicly I'm doing the beginners tutorial and it should show this

With coinbase adress

But For me it just does this

Without adresses

How can I make web3.eth.coinbase refer to my adress? Do I have to run a node or test-net?

<script type="text/javascript">
///First web3.eth.watch code to monitor coinbase


  web3.eth.watch('chain').changed(function(){
  var coinbase = web3.eth.coinbase;
  document.getElementById('coinbase').innerText = coinbase;
  var balance = web3.eth.balanceAt(coinbase);
  document.getElementById('balance').innerText = web3.toDecimal(balance);
});



///Insert your contract address var here:


///Second web3.eth.watch code to monitor block number


</script>
4
  • Tell us a bit more about your setup and the exact tutorial that you're following. If you're working with the go-to Ethereum client (geth) then you can start the JavaScript console and set it via web3.eth.coinbase=web3.eth.accounts[0] (or whatever account you choose).
    – SCBuergel
    Mar 10, 2017 at 23:57
  • I was doing this tutorial dappsforbeginners.wordpress.com/tutorials/javascript-api-1 and I just typed it into the sublimeText editor.
    – bhikkhu
    Mar 11, 2017 at 0:52
  • I added the code that I used
    – bhikkhu
    Mar 11, 2017 at 1:30
  • That is an incredibly out-of-date tutorial, unfortunately. Even if you were to connect a node, that version of web3 is long deprecated. Here is a more modern tutorial, from the official Ethereum Foundation website. Mar 11, 2017 at 13:22

3 Answers 3

1

In Geth CLI, you can set your coinbase as follows:

miner.setEtherbase("0x123...");

Edit: For web3, it is web3.miner.setEtherbase("0x123...");

1

what do you get when you go into the JS Console of your local geth node and type in the following?

eth.coinbase

and what do you get when you put in

eth.accounts[0]

This way you could check if your node has a properly configured coinbase. The second command should output your default or primary account. Using:

personal.listAccounts

will output all available accounts.

Personally I use:

miner.setEtherbase(eth.accounts[0])

to define my coinbase both in the JS Node as well as in web3.

I assume that within your HTML you point to web3.js?

0

I'm kinda new at this myself, but.....this gives you some practical guide lines into commands to get you started. have you run "geth account new"? that will attach a coinbase account to your mining operation.

https://github.com/ethereum/go-ethereum/wiki/Managing-your-accounts

2
  • Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – q9f
    Mar 14, 2017 at 12:36
  • 1
    gottcha....new to forums in general and this one specifically....but huge amounts of good info here. Mar 15, 2017 at 19:44

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.