Last active
January 26, 2021 19:32
-
-
Save BlinkyStitt/2022210db0e45d618e826c08632d0ec2 to your computer and use it in GitHub Desktop.
use brownie for debugging eth transactions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Installation: | |
- Copy/paste this into a brownie project's `scripts/tx_info.py` | |
- Change the project from "ArgobytesExtraProject" to whatever your project is named. | |
Usage: brownie run --network mainnet scripts/tx_info.py | |
""" | |
import brownie | |
from brownie._cli import console | |
def debug_shell(extra_locals): | |
shell = console.Console(project.ArgobytesExtraProject, extra_locals) | |
shell.interact(banner="Debug time.", exitmsg="") | |
def main(): | |
while True: | |
try: | |
tx_id = input("tx id (ctrl+d to exit): ") | |
except EOFError: | |
break | |
print_tx_info(tx_id) | |
print("\n\nGoodbye!") | |
def print_tx_info(tx): | |
tx = brownie.chain.get_transaction(tx) | |
print() | |
tx.info() | |
print() | |
tx.call_trace() | |
if tx.status == 0: | |
# revert! | |
print() | |
tx.traceback() | |
print() | |
print("Sometimes useful, but often slow: tx.trace") | |
print() | |
print("[ctrl+d] to check another transaction") | |
print() | |
debug_shell(locals()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment