If I just have someone else's ETH contract bytecod an ABI, how can I test it's function?
-
By writing code.– goodvibrationMay 5, 2020 at 15:39
-
Sorry,I don‘t understand what you mean,please show me the detail step.– Ds.HaleMay 5, 2020 at 15:43
-
You show me yours, and then I'll show you mine. Do we have a deal?– goodvibrationMay 5, 2020 at 15:44
-
For example,there is a ETH contract with only bytecode,now I want to test it,what shoud I do?– Ds.HaleMay 5, 2020 at 15:48
2 Answers
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.