2

For some testing I deployed several contracts on Ropsten Testnet using web3.py but now if I want to execute them or call any function from them, how can I do this? I don't have ABI as I did several contracts and its practically impossible for me to verify every single contract. I have only Transaction hash and the contract address.

Please help

4
  • I don't think there is a way you can execute your contract if you don't have ABI and address unless it's a standard contract like ERC-20. Commented Jan 16, 2019 at 12:19
  • neither any way to interact with?
    – Tabz
    Commented Jan 16, 2019 at 12:22
  • How do you know what the contract's functionality is if you don't have the ABI? Commented Jan 16, 2019 at 14:09
  • Do you have the source code of the contracts? You can generate the ABI from source.
    – rhlsthrm
    Commented Mar 8, 2019 at 17:43

3 Answers 3

0

There is (almost) no way to get the ABI if you only have the transaction hash and/or contract address.

I said almost because it is possible to reverse-engineer the contract. At least in theory. Reverse-engineering is always a difficult process and it might not work. There are some tools which attempt to do it for you but I don't really know how accurate they are.

Some more info on reverse-engineering: Is there a way to extract ABI from a deployed contract?

Just to clarify some confusion in an another answer's comments: verifying your code on Etherscan isn't really a Ethereum term. It's only functionality which was (possibly) invented by Etherscan team. It's a handy feature but it's not necessary in any way. You can publish your code in the blockchain without providing the source code to anyone.

0

You don't need the full ABI assuming you know the specific function signature you are trying to call.

I see you asked for web3.py but I'm not familiar with that. Here's the API's of interest from web3.js... hopefully you can find the equivalent in .py.

https://web3js.readthedocs.io/en/1.0/web3-eth-abi.html#encodefunctioncall https://web3js.readthedocs.io/en/1.0/web3-eth.html#sendtransaction

So the code looks something like:

let call = web3.eth.abi.encodeFunctionCall({
    name: 'myMethod',
    type: 'function',
    inputs: [{
        type: 'uint256',
        name: 'myNumber'
    },{
        type: 'string',
        name: 'myString'
    }]
}, ['2345675643', 'Hello']);
let tx = await web3.eth.sendTransaction(call, {to: contract_address})

hth

-1

https://ropsten.etherscan.io/address/0x479955ee1b96bc0b6fff39317e567c373910e39f#code

Replace "0x479955ee1b96bc0b6fff39317e567c373910e39f" with address of your contract, it will show you the source code and ABI, if it is deployed over Ropsten network.

5
  • as I mentioned my code is not verified, I deployed several contracts so its practically impossible for me to verify one by one
    – Tabz
    Commented Jan 16, 2019 at 12:15
  • What do you mean by 'verify' ? if you deployed your code over ropsten it must be on the network and enlisted on etherscan, you can get the abi and call any method using its address.
    – sp4c3
    Commented Jan 16, 2019 at 12:19
  • 2
    When we deploy any contract on ethereum (no matter testnet or main net) you must go and do verify and publish.
    – Tabz
    Commented Jan 16, 2019 at 12:21
  • Oh, I was not aware about that. Well, do you have access to the transaction objects and contract runtime code hash. I've not worked on ropsten, I'm just checking if you have any trace of past transactions. Like with Geth you can just re-open nodes to get this stuff.
    – sp4c3
    Commented Jan 16, 2019 at 14:30
  • Well that is just incorrect. Nobody forces you to verify your code. Verifying is just an Etherscan term anyway, albeit an useful one. Commented Mar 8, 2019 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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