1

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

Thanks in advance :)

1 Answer 1

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

3
  • 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. Commented Oct 23, 2018 at 12:02
  • I think pow hash is hash in the block header
    – Tony Dang
    Commented Oct 24, 2018 at 1: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
    Commented Oct 24, 2018 at 8:56

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.