Skip to content

Commit

Permalink
Add wasmd section
Browse files Browse the repository at this point in the history
  • Loading branch information
pinosu committed Jul 5, 2024
1 parent eb4f361 commit 221555d
Show file tree
Hide file tree
Showing 10 changed files with 314 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/pages/_meta.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"index": "Welcome",
"core": "CosmWasm Core",
"wasmd": "Wasmd",
"ibc": "IBC",
"sylvia": "Sylvia",
"cw-storage-plus": "cw-storage-plus",
Expand Down
8 changes: 8 additions & 0 deletions src/pages/wasmd.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Introduction

Wasmd is a Cosmos-SDK sample application that integrates the `x/wasm` module,
providing full support for Wasm smart contracts while maintaining the standard
features of a Cosmos-based blockchain. `x/wasm` is an essential module for
developers looking to build Cosmos SDK-based blockchains where they can deploy,
execute, and manage Wasm smart contracts. In this section you will learn how to
set up `wasmd` and integrate `x/wasm` in your blockchain.
4 changes: 4 additions & 0 deletions src/pages/wasmd/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"getting-started": "Getting Started",
"integration": "Integration"
}
4 changes: 4 additions & 0 deletions src/pages/wasmd/getting-started.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Getting Started

This part of the documentation describes how to set up wasmd, start a node, and
interact with it using the CLI.
5 changes: 5 additions & 0 deletions src/pages/wasmd/getting-started/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"setup": "Set Up Your Local Environment",
"run-node": "Run A Node",
"cli": "Interact via the CLI"
}
214 changes: 214 additions & 0 deletions src/pages/wasmd/getting-started/cli.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
# Interact via the CLI

## Tx commands

### Upload code

You can upload your contract by running the following command. In this example
we are uploading the `hackatom.wasm` contract.

```sh
wasmd tx wasm store "$DIR/../../../x/wasm/keeper/testdata/hackatom.wasm" \
--from validator \
--chain-id=testing \
--keyring-backend=test
```

You can retrieve the code_id for the uploaded contract with the following
command:

```sh
RESP=$(wasmd q tx $(echo "$RESP"| jq -r '.txhash') -o json)
CODE_ID=$(echo "$RESP" | jq -r '.events[]| select(.type=="store_code").attributes[]| select(.key=="code_id").value')

# Print code id
echo "* Code id: $CODE_ID"
```

### Create a new contract instance

You can instantiate the code uploaded in the previous step with th efollowing
command:

```sh
wasmd tx wasm instantiate "$CODE_ID" "{}" \
--from validator \
--no-admin \
--label "local0.1.0" \
--chain-id=testing \
--keyring-backend=test
```

You can retrieve the contract address for the instantated code with the
following command:

```sh
CONTRACT=$(wasmd query wasm list-contract-by-code "$CODE_ID" -o json | jq -r '.contracts[-1]')

# Print contract address
echo "* Contract address: $CONTRACT"
```

### Create a new contract instance with predictable address

```sh
wasmd tx wasm instantiate2 "$CODE_ID" "{}" 10 \
--from validator \
--no-admin \
--label "local0.1.0" \
--chain-id=testing \
--keyring-backend=test
```

You can retrieve the contract address for the instantated code with the
following command:

```sh
CONTRACT_PREDICTABLE=$(wasmd query wasm list-contract-by-code "$CODE_ID" -o json | jq -r '.contracts[-1]')

# Print contract address
echo "* Contract address: $CONTRACT_PREDICTABLE"
```

### Execute a command on a wasm contract

To execute a command on a wasm contract you can run the following commands:

```sh
# Define message
MSG='{"release":{}}'

# Execute message
wasmd tx wasm execute "$CONTRACT" "$MSG" \
--from validator \
--chain-id=testing \
--keyring-backend=test
```

### Migrate a wasm contract to a new code version

```sh
wasmd start
```

### Submit proposal

```sh
wasmd start
```

### Update instantiate config

```sh
wasmd start
```

### Set contract label

```sh
wasmd start
```

### Set contract admin

```sh
wasmd start
```

### Clear contract admin

```sh
wasmd start
```

### Clear contract admin

```sh
wasmd start
```

### Grant code upload permissions

```sh
wasmd start
```

### Grant contract execute permissions

```sh
wasmd start
```

### Grant contract migrate permissions

```sh
wasmd start
```

## Query commands

### Query wasm bytecode

```sh
wasmd start
```

### Query code id metadata

```sh
wasmd start
```

### Query contract metadata

```sh
wasmd start
```

### Query contract history

```sh
wasmd start
```

### Query contract state

```sh
wasmd start
```

### Query libwasmvm version

```sh
wasmd start
```

### Query codes

```sh
wasmd start
```

### Query contracts by code id

```sh
wasmd start
```

### Query contracts by creator

```sh
wasmd start
```

### Query parameters

```sh
wasmd start
```

### Query pinned contracts

```sh
wasmd start
```
32 changes: 32 additions & 0 deletions src/pages/wasmd/getting-started/run-node.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Run A Node

To review all the details on how to run a node, visit
[this tutorial](https://tutorials.cosmos.network/tutorials/3-run-node/). Below,
we provide a script to do it quickly.

## Setup Node

Run the following script

```sh
#init chain
wasmd init --chain-id "CHAIN_ID" "MONIKER"

# add a new key
wasmd keys add alice --keyring-backend=test

# add an account
wasmd genesis add-genesis-account validator "1000000000000$STAKE,1000000000000$FEE" --keyring-backend=test

wasmd genesis gentx validator "250000000$STAKE" --chain-id="$CHAIN_ID" --amount="250000000$STAKE" --keyring-backend=test

wasmd genesis collect-gentxs
```

## Start node

To start the node run:

```sh
wasmd start
```
42 changes: 42 additions & 0 deletions src/pages/wasmd/getting-started/setup.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Callout } from "nextra/components";

# Set Up Your Local Environment

## Install Go

To build and install Wasmd, Go is required. If you haven't installed Go yet, you
can set it up by visiting the
[Go download and install page](https://go.dev/doc/install).

<Callout>The latest version of wasmd requires `go version v1.21`.</Callout>

## Set Up Wasmd

Clone wasmd repository

```sh
git clone https://github.com/CosmWasm/wasmd.git && cd wasmd
```

Select the most stable version

```sh
git checkout v0.51.0 # replace the v0.51.0 with the most stable version
```

Install wasmd

```sh
make install
```

You can verify the version of Wasmd you have once it is installed:

```sh
wasmd version
```

<Callout type="warning">
Running a node on Windows OS is not supported yet. You can build a wasmd
client for Windows using `make build-windows-client`.
</Callout>
3 changes: 3 additions & 0 deletions src/pages/wasmd/integration.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Integration

This part of the documentation describes how to integrate wasmd in your project.
1 change: 1 addition & 0 deletions src/pages/wasmd/integration/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}

0 comments on commit 221555d

Please sign in to comment.