Skip to content

Examples

Jonathan Becker edited this page Feb 2, 2023 · 14 revisions

This page shows you what is possible with some of the tools heimdall-rs offers.

Modules

Decompile

Generating Contract ABI

The decompile module allows you to generate the contract ABI for events, functions, and errors it discovers. Eventually, this module will support generating solidity from bytecode.

heimdall decompile 0x1bf797219482a29013d804ad96d1c6f84fba4c45 -vvv

image

Generating Contract Solidity

The decompile module also allows you to generate a rough view of the solidity code that the contract was compiled with. As this is not a straightforward problem, some of the solidity might not make sense.

heimdall decompile 0x1bf797219482a29013d804ad96d1c6f84fba4c45 -vvv -d --include-sol --skip-resolving

image

Decode

Decoding a Seaport Transaction

Decoding a Token Transfer

The decode module allows you to decode transactions without the need for an ABI. Let's use it to decode a token transfer.

heimdall decode 0x407f778608b8cef83a7f40f60c3433c67620997f2f27b4193d8bbb46d6ebaf5b -vvv

image

Decoding a Seaport Transaction

Seaport is an incredible complex protocol, yet heimdall-rs handles decoding many of its transactions beautifully:

heimdall decode 0xa6b45854e7d112ae902e1b1b3ec6dbc46bc625bbc88ce95d54dba62656ad649e -d

image

CFG

Generating A Dot File

The CFG Module generates the control-flow graph of a contract's bytecode using graphviz's dot files. These files can be visualized by VSCode, or even converted to PNGs using external tools.

heimdall cfg 0x1bf797219482a29013d804ad96d1c6f84fba4c45 -vvv
image

If you inspect the generated .dot file, you get the following:

image
Generating an SVG File

You can also generate an SVG file using --format svg. This is useful if you want to view the CFG in a browser.

heimdall cfg 0x1bf797219482a29013d804ad96d1c6f84fba4c45 -vvv --format svg
image
Full Generated SVG