metashrew-cli
metashrew-cli
Scaffold WASM builds that can run in the metashrew runtime.
Install
Usage
As an example, we will scaffold a metaprotocol that implements DNS on Bitcoin:
Once this completes, you will have a ./dns-on-bitcoin
directory that is fully installed and can execute the included scripts.
The build outputs a ./build/release.wasm
which can be run directly in metashrew via its --indexer
flag.
Find metashrew here:
https://github.com/sandshrewmetaprotocols/metashrew
The boilerplate simply imports metashrew-as
which you can find here:
https://github.com/sandshrewmetaprotocols/metashrew-as
Edit the entrypoint _start
which can be found in ./assembly/index.ts
Metaprotocols built with metashrew-cli
use AssemblyScript as a compiler. This is the same compiler used for building subgraphs, for developers coming from Ethereum development. Refer to the AssemblyScript docs here:
https://www.assemblyscript.org/introduction.html
You don't have to build metaprotocls in AssemblyScript alone. The WASM builds can link to Rust sources built with no_std with wasm-pack or similar WASM build crates.
Anything that compiles to WASM can link to the binaries produced with this CLI.
Testing
The boilerplate project generated by this CLI includes metashrew-test
which is a mock runtime for metashrew. This allows you to write test cases with mock block data and check your key-value pairs after program run. More complex testing can be accomplished using this IndexerProgram class.
To run the included tests, execute: