From 349aa9f6b7b3a6230b4d648a6c4b8b8c4e2898fb Mon Sep 17 00:00:00 2001 From: Piotr Rudnik Date: Tue, 29 Mar 2022 11:18:56 +0200 Subject: [PATCH] Fix incorrect usage of toChecksumAddress from web3 --- ethtx/providers/web3_provider.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ethtx/providers/web3_provider.py b/ethtx/providers/web3_provider.py index 3853affe..822b6362 100644 --- a/ethtx/providers/web3_provider.py +++ b/ethtx/providers/web3_provider.py @@ -258,7 +258,7 @@ def get_code_hash( self, contract_address: str, chain_id: Optional[str] = None ) -> str: chain = self._get_node_connection(chain_id) - byte_code = chain.eth.get_code(Web3.toChecksumAddress(contract_address)) + byte_code = chain.eth.get_code(Web3.toChecksumAddress(contract_address[-40:])) code_hash = Web3.keccak(byte_code).hex() return code_hash @@ -338,7 +338,7 @@ def get_erc20_token( def guess_erc20_token(self, contract_address, chain_id: Optional[str] = None): chain = self._get_node_connection(chain_id) - byte_code = chain.eth.get_code(Web3.toChecksumAddress(contract_address)).hex() + byte_code = chain.eth.get_code(Web3.toChecksumAddress(contract_address[-40:])).hex() if all( "63" + signature[2:] in byte_code