For some contracts, the Etherscan api returns empty bytecode (0x). For example for:
- 8AB399CBB9FDB9A36518A7E7EDDF89158E56C595 (even though the contract exists: https://etherscan.io/address/0x8AB399CBB9FDB9A36518A7E7EDDF89158E56C595 )
- A9131EC8390D9AE069A061A4898B8A35495C4259 (even though this contract also exists: https://etherscan.io/address/0xA9131EC8390D9AE069A061A4898B8A35495C4259 )
For some other contracts, the API functions properly:
- C1E088fC1323b20BCBee9bd1B9fC9546db5624C5 (https://etherscan.io/address/0xc1e088fc1323b20bcbee9bd1b9fc9546db5624c5#multichain-portfolio )
I need the deployed bytecode to implement my simulation of the EXTCODEHASH opcode.
Does the API not function properly?
The source code of my API call for clarity:
@classmethod
def _fetch_contract_source_code(cls, contract_address, api_key, api_base_url):
params = {
'module': 'proxy',
'action': 'eth_getCode',
'address': contract_address,
'apikey': api_key
}
response = requests.get(api_base_url, params=params)
if response.status_code != 200:
raise Exception(f'Error fetching source code: {response.status_code} - {response.text}')
data = response.json()
if len(data['result']) < 3:
return False
return data['result'];