Closed ylasgamers closed 5 months ago
@ylasgamers It looks like you are using Python 3.7 which is no longer supported and also an old version of web3.py seeing as many of the methods you are invoking are still camelCase.
Using the latest web3.py I have no issues getting the proof from the example you just posted:
account = w3.to_checksum_address("0x6C8f2A135f6ed072DE4503Bd7C4999a1a17F824B")
block_number = w3.eth.block_number
block = w3.eth.get_block(block_number)
proof = w3.eth.get_proof(account, [0, 1], block_number)
What happened?
ValueError: {'code': -32602, 'message': 'invalid argument 1: json: cannot unmars hal hex string of odd length into Go value of type common.Hash'}
Code that produced the error
from web3 import Web3, HTTPProvider import json import time
web3 = Web3(Web3.HTTPProvider("https://eth-pokt.nodies.app"))
if web3.isConnected(): print("Successfully connected") else: print("Error connecting")
from eth_utils import ( keccak, ) import rlp from rlp.sedes import ( Binary, big_endian_int, ) from trie import ( HexaryTrie, ) from web3._utils.encoding import ( pad_bytes, )
def format_proof_nodes(proof): trie_proof = [] for rlp_node in proof: trie_proof.append(rlp.decode(bytes(rlp_node))) return trie_proof
def verify_eth_get_proof(proof, root): trie_root = Binary.fixed_length(32, allow_empty=True) hash32 = Binary.fixed_length(32)
account = web3.toChecksumAddress("0x6C8f2A135f6ed072DE4503Bd7C4999a1a17F824B")
block_number = web3.eth.blockNumber block = web3.eth.get_block(block_number) proof = web3.eth.get_proof(account, [0, 1], block_number) assert verify_eth_get_proof(proof, block.stateRoot)
No response
Full error output
Fill this section in if you know how this could or should be fixed
No response
web3 Version
No response
Python Version
No response
Operating System
No response
Output from
pip freeze
No response