Skip to content

Modules

Jonathan Becker edited this page May 28, 2024 · 28 revisions

This page outlines the general documentation for all modules in the heimdall-rs toolkit.

Shared Options

These options are shared by nearly all modules on heimdall-rs, and have the same functionality across all modules.

Option Description
-v, --verbose More verbose output per occurrence
-q, --quiet Silence output
-r <RPC_URL>, --rpc-url <RPC_URL> The RPC provider to use when connecting to an RPC node
-h, --help Show the help message
-o, --output Set the output directory for generated files, or print to display in the terminal
-n, --name Customize the name of generated files

Verbosity

The -v option can be used to increase the verbosity of heimdall-rs. This can be useful for debugging issues with heimdall-rs. The -v option can be used multiple times to increase the verbosity of heimdall-rs. Output can be silenced with the -q flag.

Option Level
-v Info
-vv Debug
-vvv Trace
-vvvv Full

RPC URL

The -r option can be used to specify the RPC URL to use when connecting to an RPC node. This RPC URL can theoretically be used on any EVM compatible chain, as long as the data it is fetching is from the same chain.

This option is used for interacting with the RPC node within the module.

Output

The -o option can be used to specify the output file or directory to use when writing output from heimdall-rs.


Modules

Config

This module allows you to display and edit the current configuration of heimdall-rs.

To view the current configuration of heimdall-rs, run heimdall config.

If you want to edit the configuration of heimdall-rs, run heimdall config <key> <value>. This will set the key to the value specified, if it's a valid configuration key.

Disassemble

This module allows you to convert raw EVM bytecode to opcodes.

Usage:

$ heimdall disassemble <TARGET> [OPTIONS]

Options

Option Description
TARGET The target to disassemble, either a file, bytecode, contract address, or ENS name
-d, --decimal-counter Whether to use base-10 for the program counter

Decode

This module allows you to decode raw calldata into readable types, without the need for an ABI.

Usage:

$ heimdall decode <TARGET> [OPTIONS]

Options

Option Description
TARGET The target to decode, either a transaction hash or string of bytes
-d, --default When prompted, always select the default value
-o <OPENAI_API_KEY>, --openai-api-key <OPENAI_API_KEY> Your OpenAI API key, used for explaining calldata
--explain Whether to explain the decoded calldata using OpenAI's GPT
-t, --truncate-calldata Whether to truncate nonstandard sized calldata. May help when decoding nonstandard calldata

Decompile

This module converts raw contract bytecode into solidity code and it's corresponding ABI.

Usage:

$ heimdall decompile <TARGET> [OPTIONS]

Note: You can also use the cloud based heimdall-rs decompiler here

Options

Option Description
TARGET The target to decode, either a transaction hash or string of bytes
-d, --default When prompted, always select the default value
--skip-resolving Whether to skip resolving function selectors
--include-sol Whether to include decompiled solidity code in the output
--include-yul Whether to include decompiled yul code in the output

CFG

This module generates a visual control flow graph for EVM bytecode.

Usage:

$ heimdall cfg <TARGET> [OPTIONS]

Options

Option Description
TARGET The target to decode, either a transaction hash or string of bytes
-c, --color-edges Color the edges of the graph based on the JUMPI condition.
-f, --format An optional format to convert the output to. Must be supported by graphviz.

Dump

This module will dump all storage slots and values within an EVM smart contract.

Usage:

$ heimdall dump <TARGET> [OPTIONS]

Options

Option Description
TARGET The target to find and dump the storage slots of
-t <API_KEY>, --transpose-api-key <API_KEY> Your Transpose.io API Key, required for fetching interactions. You can obtain a free one here
--threads <THREAD_COUNT> The number of threads to use when fetching storage values
--from-block <FROM_BLOCK> The block number to start dumping from
--to-block <TO_BLOCK> The block number to stop dumping at
--no-tui Whether to skip opening the TUI
--chain <CHAIN> The chain of the target. Default to ethereum. One of ethereum, canto, polygon, arbitrum, or goerli

TUI Commands & Controls

In this section we'll discuss how to use the commands and controls of the TUI, which is used to view and interact with the large amount of data in a more elegant fashion. The commands and controls of the dump module TUI are as follows:

Commands Description
:q, :quit exit the program
:h, :help display this help menu
:f, :find <VALUE> search for a storage slot by slot or value
:e, :export <FILENAME> export the current storage dump to a file, preserving decoded values
:s, :seek <DIRECTION> <AMOUNT> move the cursor up or down by a specified amount
Controls Description
↑, Scroll Up move the cursor up one slot
↓, Scroll Down move the cursor down one slot
←, → change the decoding type of the selected slot
CTRL + ↑, CTRL + ↓ move the cursor up or down by 10 slots
ESC clear the search filter

Inspect

Detailed inspection of Ethereum transactions, including calldata & trace decoding, log visualization, and more

Usage:

$ heimdall inspect <TARGET> [OPTIONS]

Options

Option Description
TARGET The transaction hash to inspect
-d, --default When prompted, always select the default value
-t <API_KEY>, --transpose-api-key <API_KEY> Your Transpose.io API Key, required for fetching contract labels (OPTIONAL). You can obtain a free one here