1

I have this block on Ropsten,

'difficulty': 3963642329, 
'extraData': '0xd88301080f846765746888676f312e31302e31856c696e7578'), 
'gasLimit': 8000000, 
'gasUsed': 7987824, 
'hash': '0x47b8f62c1400dae65105d2f8e03824bfc58481c0b32f45788ad3378fbc05e9f6', 
'logsBloom': '0x0800012104000104c00400108000400000003000000040008400000002800100000a00000000000001010401040001000001002000000000020020080000240200000000012260010000084800420200040000100000030800802000112020001a200800020000000000500010100a00000000020401480000000010001048000011104800c002410000000010800000000014200040000400000000000000600020c00000004010080000000020100200000200000800001024c4000000080100004002004808000102920408810000002000008000000008000120400020008200d80000000010010000008028004000010000008220000200000100100800', 
'miner': '0x6A9ECfa04e99726eC105517AC7ae1aba550BeA6c', 
'mixHash': '0x0c0026c706351083c0a913e084dee16ca133b813baa6a174e4fb179d9f2ecc52', 
'nonce': '0xf245822d3412da7f', 
'number': 4156209, 
'parentHash': '0xad22d4d8f0e94032cb32e86027e0a5533d945ed95088264e91dd71e4fbaebeda', 
'receiptsRoot': '0xeb1e644436f93be8a9938dfe598cb7fd729f9d201b6f7c0695bee883b3ea6a5b', 
'sha3Uncles': '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347', 
'size': 27324, 'stateRoot': '0x43e3325393fbc583a5a0b56e98073fb81e82d992b52406a79d662b690a4d2753', 
'timestamp': 1538483791, 
'totalDifficulty': 11844984547350924, 
'transactions': [.......], 
'transactionsRoot': '0x40c339f7715932ec591d8c0c588bacfaed9bddc7519a1e6e87cf45be639de810', 'uncles': []

and now I can recreate the transactionsRoot with a trie, but how do I prove that the transactionsRoot is acualy the txRoot of that block?

My main question is: Is the txRoot part of the blockHash? and if so, how to obtain the blockhash?

Thanks in advance :)

  • block's hash is 0x47b8f62c1400dae65105d2f8e03824bfc58481c0b32f45788ad3378fbc05e9f6 , 5th field from the top – Nulik Oct 10 '18 at 13:20
  • Yeah :) Thank you.... Actually I am trying to prove that the txroot belongs to this hash. I mean the blockhash or txroot could have been tampered with. – SimonSchuler Oct 11 '18 at 9:24
  • the only way to prove is to recalculate the data (by calling Hash() function) yourself – Nulik Oct 11 '18 at 14:26
1

I found the answer in Python:

class MyBlockHeader(rlp.Serializable):
    fields = [
        ('parentHash', hash32),
        ('sha3Uncles', hash32),
        ('miner', address),
        ('stateRoot', trie_root),
        ('transactionsRoot', trie_root),
        ('receiptsRoot', trie_root),
        ('logsBloom', int256),
        ('difficulty', big_endian_int),
        ('number', big_endian_int),
        ('gasLimit', big_endian_int),
        ('gasUsed', big_endian_int),
        ('timestamp', big_endian_int),
        ('extraData', binary),
        ('mixHash', binary),
        ('nonce', Binary(8, allow_empty=True))
    ]

    def hash(self) -> bytes:
        '''use the rlp and hash to recalculate the blockhash'''
        return keccak(rlp.encode(self))

and there the hash() includes the tx-root. So then there is the Proof that the txroot is in the Block.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.