Search code examples
ethereumsmartcontractsweb3py

Calling a smart contract without the ABI in Web3.py


I need to call a function of an implementation contract. The problem is I'm not the creator of the contract and it's source code hasn't been verified on ethersan, hence I don't have the ABI. I extracted calldata(0x12345...) from tx to the proxy contract. I know metodId and 3 args(address, uint256, address) and I modified args to my needs. Is it possible to send a transaction calling a fallback function of the proxy without implementation ABI, just with raw calldata?


Solution

  • You can simply create a transaction in the web3

    • address: Contract address

    Then add to the data field

    • First 4 bytes (32 bits): function selector
    • Following 3 * 32 bytes (256 bits): function arguments (address, uint256, address), zero-padded, so-called ABI encode