https://github.com/devlyn37/navigator
Utility CLI for EVM things
https://github.com/devlyn37/navigator
Last synced: about 1 year ago
JSON representation
Utility CLI for EVM things
- Host: GitHub
- URL: https://github.com/devlyn37/navigator
- Owner: devlyn37
- Created: 2022-09-25T16:51:26.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-21T18:35:29.000Z (over 3 years ago)
- Last Synced: 2025-02-10T02:13:21.798Z (over 1 year ago)
- Language: Rust
- Homepage:
- Size: 43.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Navigator
A CLI for things I find myself doing often in EVM land.
This is a WIP and implemented in Rust for fun
## Decode Command
I often parse through logs like this:
```
code: 'SERVER_ERROR',
body: '{"jsonrpc":"2.0","id":44,"error":{"code":3,"message":"execution reverted","data":"0xc373e55d"}}',
error: {
code: 3,
data: '0xc373e55d'
requestBody: '{"method":"eth_estimateGas","params":[{"value":,"from":,"to":,"data":"0x493610a600000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000cc5060f9674aff5d32122b29d4c52373558f0fca"}],"id":44,"jsonrpc":"2.0"}',
requestMethod: ,
url:
}
},
```
this happens when contracts revert with custom errors (ex. shown in solidity below) are thrown
```
error InsufficientBalance(uint256 available, uint256 required);
```
It's difficult to grok what's going on from the error logs, the `decode` command decodes the hex data for errors and functions like they're provided in the example above.
It does so by:
- fetching the abi
- matching the function or error signature with the data
- decoding the parameters according to that matched function or error
### Usage
```
Usage: navigator decode --kind=
Arguments:
the chain the contract is deployed to
the contract the data is related to
an api key for etherscan
the hex encoded data
Options:
--kind= [possible values: function, error]
-h, --help Print help information
```
### Examples
decoding function data
```
cargo run decode mainnet 0x1d9317911cf1003b42a965574c29f18a87a2858c 0x0209c6b7000000000000000000000000292f9d08efcf1a3a988959190d44f48a53577f100000000000000000000000000000000000000000000000000000000000000001 --kind=function
```
output:
```
function name: mintSeasonPassNFT, arguments: [Address(0x292f9d08efcf1a3a988959190d44f48a53577f10), Uint(1)]`
```
decoding error data
```
cargo run decode goerli 0x98AA442ceFCAF0A7277D10889d07d04E90B37eA5 0xd2ade556 --kind=error
```
output:
```
IncorrectValue, arguments: []
```