moonworm/README.md

98 wiersze
3.9 KiB
Markdown

2022-04-19 13:15:54 +00:00
## What is moonworm?
2021-11-02 14:53:15 +00:00
2022-04-19 13:15:54 +00:00
Moonworm is a set of tools that helps you develop/analyze blockchain dapps. Pump your productivity to the Moon.
2021-11-02 14:53:15 +00:00
2022-04-19 13:15:54 +00:00
### Tools:
2021-11-02 14:53:15 +00:00
2022-04-19 13:15:54 +00:00
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.
2022-04-19 13:21:41 +00:00
![moonworm](https://user-images.githubusercontent.com/19771534/164013435-74a9e816-74ef-4e05-a7e5-1f7f620896e7.jpg)
3. `moonworm generate` - cli/ python interface generator for pure `web3` library. In case you prefer not to use `brownie`
2021-11-02 14:53:15 +00:00
2022-04-19 13:15:54 +00:00
## Setup:
2021-11-02 14:53:15 +00:00
2022-04-19 19:02:28 +00:00
```bash
pip install moonworm
2022-04-19 13:15:54 +00:00
```
2021-11-04 13:14:26 +00:00
## Guides
- [How to `watch`](./docs/how-to-watch.md) - How to use `moonworm watch` to get data about smart contract
activity.
2021-11-02 14:53:15 +00:00
2022-04-19 13:15:54 +00:00
## Usage:
### `moonworm watch`:
```bash
moonworm watch --abi <Path to abi file> --contract <Contract address> --web3 <Web3 provider url> --start <Start block> --end <End block>
2021-11-03 15:28:16 +00:00
```
2022-04-19 13:15:54 +00:00
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:
2022-04-19 19:02:28 +00:00
- `--end/-e END` block to stop crawling, if not given, crawler will not stop
2022-04-19 13:15:54 +00:00
- `--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
2022-04-19 19:02:28 +00:00
- `--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
2022-04-19 19:06:44 +00:00
- `--max-blocks-batch MAX_BLOCKS_BATCH` Maximum number of blocks to batch together. Default=1000 **Note**: it is used only in `--only-events` mode
-
2022-04-19 13:15:54 +00:00
### `moonworm generate-brownie`:
2021-11-04 13:14:26 +00:00
```bash
2022-04-19 13:15:54 +00:00
moonworm generate-brownie -p <Path to brownie project> -o <Outdir where file will be generated> -n <Contract name>
2021-11-04 13:14:26 +00:00
```
2022-04-19 13:15:54 +00:00
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`
2022-04-19 13:15:54 +00:00
3. Run the generated cli of the contract: `python3 generated/Mycontract.py -h`
2022-04-19 13:15:54 +00:00
### `moonworm generate`:
2021-11-04 13:14:26 +00:00
```bash
2022-04-19 13:15:54 +00:00
moonworm generate --abi <Path to abi> -o <Outdir> --interface --cli --name <Prefix name for the generated files>
2021-11-04 13:14:26 +00:00
```
2022-04-19 13:15:54 +00:00
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
2022-04-19 13:15:54 +00:00
## 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](https://github.com/bugout-dev/dao/tree/main/dao), [lootbox contract](https://github.com/bugout-dev/lootbox/tree/main/lootbox)
- But ser, I dont write on python
2021-11-02 14:53:15 +00:00
2022-04-19 13:15:54 +00:00
Javascript version (hardhat) is coming soon