sel2sig
sel2sig simplifies EVM calldata/error decoding using project-generated artifacts with contracts' ABIs.
Features
Supported Libraries
Getting Started
To utilize the decoding features of sel2sig, you'll need to provide the following:
- Path to the artifacts folder within your project.
- The calldata you want to decode.
You can provide calldata in one of the following ways:
- 4-byte selector
- ABI-encoded calldata/error
- Path to logs containing an error
To build sel2sig, follow these steps:
-
Clone this repository to GOPATH/src/:
cd "$(go env GOPATH)/src" && git clone https://github.com/golden-expiriensu/sel2sig
-
Execute install script:
./install.sh
Example Usage
Below are examples of how to use the tool. Please note that all these commands were executed within the folder containing 'artifacts' folder with compilation results of OpenZeppelin's smart contracts.
-
Find origin of a selector:
$ sel2sig ./artifacts 0x70a08231
function balanceOf(address account) view returns(uint256)
-
Decode calldata:
$ sel2sig ./artifacts 0xa9059cbb000000000000000000000000e058fBFD6e991320C1Eb1B17808F742DE92410bC00000000000000000000000000000000000000000000000d8d726b7177a80000
function transfer(address to, uint256 amount) returns(bool)
decoded args: [
0xe058fBFD6e991320C1Eb1B17808F742DE92410bC,
250000000000000000000
]
-
Decode received custom error:
$ sel2sig ./artifacts 0xe450d38c000000000000000000000000e058fBFD6e991320C1Eb1B17808F742DE92410bC00000000000000000000000000000000000000000000000d8d726b7177a8000000000000000000000000000000000000000000000000001043561a8829300000
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed)
decoded args: [
0xe058fBFD6e991320C1Eb1B17808F742DE92410bC,
250000000000000000000,
300000000000000000000
]
-
Decode error logs:
$ sel2sig ./artifacts ./file_with_error_logs
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed)
decoded args: [
0xe058fBFD6e991320C1Eb1B17808F742DE92410bC,
250000000000000000000,
300000000000000000000
]
Where file_with_error_logs may include stack traces, error messages, transaction details etc
License
sel2sig is open-source software released under the MIT License. Feel free to use and modify it according to your needs.