# metashrew-cli

## 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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sandshrew.io/metashrew-open-source-repositories/metashrew-cli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
