0

If I just have someone else's ETH contract bytecod an ABI, how can I test it's function?

  • By writing code. – goodvibration May 5 at 15:39
  • Sorry,I don‘t understand what you mean,please show me the detail step. – Ds.Hale May 5 at 15:43
  • You show me yours, and then I'll show you mine. Do we have a deal? – goodvibration May 5 at 15:44
  • For example,there is a ETH contract with only bytecode,now I want to test it,what shoud I do? – Ds.Hale May 5 at 15:48
0

You must learn web3.js or web3.py in order to interact with a contract using abi and bytecode. You also need to know that contract's methods or variables in order to use or call them otherwise you need to look at the abi to see methods and variables.

| improve this answer | |
0

The bytecode contains all the functionality. The ABI tells what the function names are and what are their signatures. So with the combination of those two you can call a real contract - if you just had a contract to call.

So what you need is a local blockchain (for example Ganache) instance where you deploy the bytecode. After that, with the ABI, you can call the contract and test it.

The problem with a local instance is that you don't have the same state as the original contract - but if you only have bytecode and ABI you don't know the state anyway. You would need all the transactions to calculate the current state. But, depending on your requirements, it may be sufficient for you to test the contract with empty (default) state.

| improve this answer | |

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