Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

block.coinbase does only return 0x #201

Closed
loki-sama opened this issue Oct 20, 2018 · 5 comments
Closed

block.coinbase does only return 0x #201

loki-sama opened this issue Oct 20, 2018 · 5 comments

Comments

@loki-sama
Copy link

Expected Behavior

I expected to get accounts[0] as block.coinbase.

Current Behavior

I got 0x0000000000000000000000000000000000000000 as block.coinbase.

curl -X POST --data '{"jsonrpc":"2.0", "method":"eth_coinbase", "params":[],"id":9999}' 127.0.0.1:8545
Gives me accounts[0].

Possible Solution

Steps to Reproduce (for bugs)

  1. run ganache-cli
  2. deploy contract
pragma solidity ^0.4.24;


contract TestCoinbase {

    function getCoinbase() public returns (address){
        return block.coinbase;
    }
}
  1. call getCoinbase

Context

Try to run tests for code that uses block.coinbase.

Your Environment

Ganache CLI v6.1.8 (ganache-core: 2.2.1)
OSX 10.13.6

@davidmurdoch
Copy link
Member

Thanks for reporting this @loki-sama. I've confirmed that this is still an issue on our develop branch and have filed this bug to our issue backlog.

@nicholasjpaterno nicholasjpaterno self-assigned this Jan 17, 2020
@Goldenflamer
Copy link

This is still an issue in 2020

@nicholasjpaterno
Copy link
Contributor

@Goldenflamer Thanks for the bump on this issue. Unfortunately this is a little lower priority than some of our other issues. That said, I plan on fixing this ASAP but if this is a blocker for you we highly encourage PR's!

@davidmurdoch
Copy link
Member

block.coinbase is actually intended to be the 0x0 address, as it is the block that receives the reward. The bug is that eth_coinbase returns accounts[0].

The reason the block coinbase can't be accounts[0] by default is that each block would change the accounts balance, and would then break many tests that rely on this behavior.

This will be fixed in the next major version of ganache, where we'll allow for configuring the coinbase address.

@davidmurdoch
Copy link
Member

done in ganache@3.0.0-internal.0

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

No branches or pull requests

4 participants