txexpl
is a tool decodes EVM transactions and provides explanations according to user-customized patterns.
# Install peth if not exists
$ pip install git+https://github.com/lmy375/txexpl
# Start txexpl server.
$ python -m txexpl.main -s -p 8080
Open http://localhost:8000/. Drag the button to your bookmarks bar.
Click the bookmark on a Transaction Etherscan page to explain it.
If you'd like to use it while signing, add this file to your tampermonkey of the browser. If intercepts before you send transactions and sign Safe transactions.
You can add your own Explanation
.
A sample case is like:
swapExactTokensForTokens: 'Sell {{amountIn:balance:path[0]}} {{path[0]}} to buy >= {{amountOutMin:balance:path[-1]}} {{path[-1]}}. Swap path: {{path}}'
It renders to things below for this transaction
Sell 0.060000 * 1e18 WETH to buy >= 80411.639109 * 1e18 MOLLY. Swap path: WETH -> MOLLY
The grammar:
explanation := KEY ":" expl_text
expl_text := ( ASCII | "{{" param "}}")+
param := func_param ( ":" HINT ( ":" HINT_ARGS )? )?
func_param := NAME | NUMBER ( "." NAME | NUMBER )*
- KEY: ABI function name or full signature or 4-bytes-selector
- ASCII: Any ASCII string with out
{{
and}}
in it - NAME: Solidity argument name or tuple member name
- NUMBER: the index in definition.
- HINT: Formatter for extracted values
- HINT_ARGS: Arguments for the hint.
Current hint supported:
balance:token
A token balance in decimals of tokenpath
DEX Swap pathnames:[[key, value]]
If the extracted value matches the key, return the value.
See more examples here.
Sometimes, transaction metadata can be used as parameters to pass into solidity methods. (Consider when you are using a smart contract wallet)
here tells how to use the parameters as a transaction.
Here is the case for ERC-4337 handleOps()
handleOps:
count: ops.length
to: ops[#].sender
data: ops[#].callData
The #
above means the decoder should fill an array index from 0
to count
.