-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
314 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"getting-started": "Getting Started", | ||
"integration": "Integration" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |