Create a tool (Python script) that can produce the contract version hash
tpmccallum opened this issue · 2 comments
We hash the ABI of a contract (abiSha3)
We also hash the Bytecode of a contract (bytecodeSha3)
We combine these to create a unique identifier (abiSha3BytecodeSha3)
This is a great way to deterministically identify a unique instance of a contract (in cases where different unique contract instances can share the same ABI but have different Bytecode etc.)
Whilst the search engine does all of this automatically as part of its normal operation, it would also be great to be able to generate the hashes manually. This would be useful for frontend developers who want to know what value to set as the dappVersion in their display etc.
This code could be kept in the Python utilities directory.
There are a few files that demonstrate how to use the main Harvest class to create both ABI and Bytecode Sha3 hashes.
https://github.com/second-state/smart-contract-search-engine/blob/multiple_canonical_abi_support/python/manually_compare_erc20_abis.py
The above files include examples of using ABIs from URLs as well as ABIs which are pasted in as text. They also include using Bytecode from GitHub URLs.