Generate command line and a python interface to any Ethereum smart contract
 
 
Go to file
Neeraj Kashyap 9f9f772092
Merge pull request #123 from moonstream-to/fix-tuple-array-parser
Fixing the tuple array parsing. Now type=eval is included
2024-04-09 10:13:59 -07:00
.github/workflows Release pypi work with token 2023-08-30 11:15:10 +00:00
docs Filter out unnamed items from ABI on `moonworm watch` 2023-09-04 20:30:34 -07:00
moonworm Bumped version to 0.9.0 2024-04-09 10:13:04 -07:00
.gitignore WIP brownie interface 2021-12-03 01:22:31 +03:00
.gitmodules remove centipede 2021-11-03 14:16:27 +03:00
.isort.cfg Added isort to requirements and lint check for all python versions 2021-11-05 11:51:47 +00:00
LICENSE Initial commit 2021-09-07 11:03:44 -07:00
MANIFEST.in added data to distrubution 2021-11-03 15:17:32 +03:00
README.md Filter out unnamed items from ABI on `moonworm watch` 2023-09-04 20:30:34 -07:00
mypy.ini Working brownie generator 2021-12-03 13:47:46 -08:00
setup.py Merge pull request #113 from moonstream-to/arbitrary-cli-argtypes 2023-08-09 13:19:34 -07:00

README.md

What is moonworm?

Moonworm is a set of tools that helps you develop/analyze blockchain dapps. Pump your productivity to the Moon.

Tools:

  1. moonworm watch - Tool to monitor and crawl(index) decoded smart contract data. It gets you historic/on going smart contracts decoded events and transactions. No sweat, just provide abi and smart contracts address and get stream of data. With this tool you can: analyze incidents, set up alerting, build datasets, write sniping bots, etc.
  2. moonworm generate-brownie - Brownie on steroids. Generate python interface and cli for your smart contracts in “one click”, focus on smart contract development, moonworm will do the rest. In addition, you will have syntax highlights which will boost your speed on writing tests. moonworm
  3. moonworm generate - cli/ python interface generator for pure web3 library. In case you prefer not to use brownie

Setup:

pip install moonworm

Guides

  • How to watch - How to use moonworm watch to get data about smart contract activity.

Usage:

moonworm watch:

moonworm watch --abi <Path to abi file> --contract <Contract address> --web3 <Web3 provider url> --start <Start block> --end <End block>

Arguments:

  • --abi/-i ABI Path to abi file
  • --contract/-c CONTRACT Contract address
  • --web3/-w WEB3 Web3 provider uri
  • --start/-s START block to start watching

Optional args:

  • --end/-e END block to stop crawling, if not given, crawler will not stop
  • --poa Flag for PoA networks, for example polygon
  • --confirmations CONFIRMATIONS Number of confirmations to set for watch. (Default 12)
  • --outfile/-o OUTFILE JSONL file into which to write events and transactions
  • --db Use Moonstream database specified by MOONSTREAM_DB_URI to get blocks/transactions. If set, need also provide --network
  • -network {ethereum,polygon}Network name that represents models from db. If the --db is set, required
  • --only-events Flag, if set: only watches events. Default=False
  • --min-blocks-batch MIN_BLOCKS_BATCH Minimum number of blocks to batch together. Default=100
  • --max-blocks-batch MAX_BLOCKS_BATCH Maximum number of blocks to batch together. Default=1000 Note: it is used only in --only-events mode

moonworm generate-brownie:

moonworm generate-brownie -p <Path to brownie project> -o <Outdir where file will be generated> -n <Contract name>

Arguments:

  • --project/-p PROJECT path to brownie project.
  • --outdir/-o OUTDIR Output directory where files will be generated.
  • --name/-n NAME Prefix name for generated files

NOTE: For better experience put generated files in sub directory of your brownie project. As an example:

  1. cd myBrownieProject

  2. moonworm generate-brownie -p . -o generated/ -n MyContract

    1. Run the generated cli of the contract: python3 generated/Mycontract.py -h

moonworm generate:

moonworm generate --abi <Path to abi> -o <Outdir> --interface --cli --name <Prefix name for the generated files>

Arguments:

  • --abi/-i ABI Path to contract abi JSON file
  • --outdir/-o OUTDIR Output directory where files will be generated.
  • --interface Flag to generate python interface for given smart contract abi
  • -name/-n NAME Prefix name for generated files
  • --cli Flag to generate cli for given smart contract abi

FAQ:

  • Ser, is it safe to use?

    Yes, it is. moonworm is a code generator that generates code that uses brownie/web3.

  • Ok ser, are there examples of usages?

    moonstream-dao contracts, lootbox contract

  • But ser, I dont write on python

    Javascript version (hardhat) is coming soon