1

I am trying to obtain the pow-hash of a block. Is there a way of doing this easy?

Thanks in advance :)

SimonSchuler
  • 318
  • 1
  • 11

1 Answers1

1

On the go-ethereum source code, you can see that the pow-hash is the hash of the block header

// SealHash returns the hash of a block prior to it being sealed.
func (ethash *Ethash) SealHash(header *types.Header) (hash common.Hash) {
    hasher := sha3.NewKeccak256()

    rlp.Encode(hasher, []interface{}{
        header.ParentHash,
        header.UncleHash,
        header.Coinbase,
        header.Root,
        header.TxHash,
        header.ReceiptHash,
        header.Bloom,
        header.Difficulty,
        header.Number,
        header.GasLimit,
        header.GasUsed,
        header.Time,
        header.Extra,
    })
    hasher.Sum(hash[:0])
    return hash
}

You can using JSON RPC to get block information from free infura endpoint and pick out the hash in the block header

for example

curl -X POST \
  https://mainnet.infura.io/v3/YOUR_API_KEY \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: 05e4a4b4-1476-4d79-9771-38dc56aa16e6' \
  -d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x6432AA", true],"id":1}'

YOUR_API_KEY is your api key from your infura dashboard account.

Or just parsing the html output from etherscan.io :)

https://etherscan.io/block/6566570

Tony Dang
  • 2,151
  • 2
  • 9
  • 16
  • Thank you :) But if I am not mistaken the BlockHeaderHash is not the same as the ProofOfWorkHash in ethereum? Am I wrong? And in the rpc-response there is no field POW-Hash. – SimonSchuler Oct 23 '18 at 12:02
  • I think pow hash is hash in the block header – Tony Dang Oct 24 '18 at 01:01
  • I put more the source code from ethereum to convince you that pow-hash is the hash of the block header :) please check it out! – Tony Dang Oct 24 '18 at 08:56