Skip to content

sandshrewmetaprotocols/metashrew-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

metashrew-cli

Scaffold WASM builds that can run in the metashrew runtime.

Install

git clone https://github.com/sandshrewmetaprotocols/metashrew-cli
cd metashrew-cli
npm install -g metashrew-cli

Usage

As an example, we will scaffold a metaprotocol that implements DNS on Bitcoin:

metashrew-cli new dns-on-bitcoin

Once this completes, you will have a ./dns-on-bitcoin directory that is fully installed and can execute the included scripts.

cd dns-on-bitcoin
yarn build

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:

yarn test

Author

Sandshrew Inc

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published