Converting the contract of jaredfromsubway.eth
from bytecode to Huff and write some test to validate the behavior.
The goal is to decompile the contract to understand its logic and create a readable version. This allows us all to learn for it. To achieve this, tests are created to validate the behavior of both the deployed and the decompiled contract.
The original contract was probably not created with Huff. Huff always appends the CODECOPY
parts at the end of the contract. Jared's contract makes use of a wall of STOP operations to keep the data. For this reason, the decompiled version is longer, and there are some adjustments to keep the JUMPDEST
instructions in the same place. Currently, not all jump destinations are likely in the correct place.
The contract was deployed on Mar-09-2024 03:47:35 AM UTC.
Contract: 0x6b75d8AF000000e20B7a7DDf000Ba900b4009A80
Deployment: tx
src/
Jared.huff <- decoded contract
decompile-contract/
resources/
disassembled.evm <- original contract
disassembled.evm <- disassembled contract
src/
decompile_contract/convert_to_huff.py <- script to convert the contract to huff
test/
BasicTests.t.sol <- test the Huff contract
In the test you can modify if the Huff version or the original constructor should be used.
export ETH_MAINNET_HTTP=<RPC PROVIDER>
forge test
The disassembled version in decompile-contract/resources/disassembled.evm
was created using heimdall-rs.
heimdall disassemble 0x6b75d8AF000000e20B7a7DDf000Ba900b4009A80
If you like to improve the decompiler I am happy to get your help. The decompiler is written in python
- Create a python virtual environment and install the dependencies:
cd decompile-contract
pip install -e .
- Run the decompiler:
python src/decompile_contract/convert_to_huff.py