Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs deploy on chiado #965

Merged
merged 12 commits into from
Nov 5, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ You can skip this guide and test a preconfigured Keychain. Just run a local node
2. Clone the repository with Warden source code. Then build the binary and initialize the chain home folder:

```bash
git clone --depth 1 --branch v0.4.2 https://github.com/warden-protocol/wardenprotocol
git clone --depth 1 --branch v0.5.2 https://github.com/warden-protocol/wardenprotocol
cd wardenprotocol
just build
just install
just wardend build
just wardend install
wardend init my-chain-moniker
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ Before you start, do the following:

Start by creating a WASM contract that will burn tokens on the EVM contract:

1. Create a CosmWasm project. You can [use a template](deploy-a-wasm-contract#1-create-a-cosmwasm-project).
1. Create a CosmWasm project. You can [use a template](deploy-a-wasm-contract#2-create-a-cosmwasm-project).

2. In the `/src` directory of your project, create a `contract.rs` file with the code below. If you've used a template, update the existing file.

Expand Down Expand Up @@ -405,7 +405,7 @@ Start by creating a WASM contract that will burn tokens on the EVM contract:

### 2.2. Add supporting code

In the following steps, you'll create files in the `/src` folder to add supporting code for your contract. If you're using a [CosmWasm project template](deploy-a-wasm-contract#1-create-a-cosmwasm-project), just update the existing files.
In the following steps, you'll create files in the `/src` folder to add supporting code for your contract. If you're using a [CosmWasm project template](deploy-a-wasm-contract#2-create-a-cosmwasm-project), just update the existing files.
ijonele marked this conversation as resolved.
Show resolved Hide resolved

1. Create a file named `msg.rs` with the following code:

Expand Down Expand Up @@ -619,7 +619,7 @@ In the following steps, you'll create files in the `/src` folder to add supporti

### 2.3. Compile & optimize

Now you can [compile](deploy-a-wasm-contract#3-compile-the-contract) and [optimize](deploy-a-wasm-contract#4-optimize-the-code) your contract.
Now you can [compile](deploy-a-wasm-contract#4-compile-the-contract) and [optimize](deploy-a-wasm-contract#5-optimize-the-code) your contract.

### 2.4. Create a Warden account

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,85 @@ Before you start, complete the following prerequisites:

- [wasm-opt](https://docs.rs/wasm-opt/latest/wasm_opt/index.html): A tool for optimizing the compiled WebAssembly (Wasm) code.

To install these tools, run the following commands:

```bash
rustup target add wasm32-unknown-unknown
cargo install cargo-generate --features vendored-openssl
brew install binaryen
```

- [Run a local chain](/operate-a-node/run-a-local-chain) and make sure you have `wardend` correctly installed.
## 1. Prepare the chain

The next steps require your local account name, or key name. You can check the list of available keys by executing this command:
### Option 1. Run a local chain

```bash
wardend keys list
```
:::tip
If you used our `just` script to run the node with default settings, the local account name is `shulgin`.
:::
1. Run a local chain as explained here: [Run a local chain](/operate-a-node/run-a-local-chain). Note that you'll need to [install Go](https://golang.org/doc/install) 1.22.3 or later and [just](https://github.com/casey/just) 1.34.0 or later.

2. The next steps require your local account name, or key name. You can check the list of available keys by executing this command:

```bash
wardend keys list
```
:::tip
If you used our `just` script to run the node with default settings, the local account name is `shulgin`.
:::

3. Check the local account balance to make sure it has funds:

<Tabs>
<TabItem value="local-default" label="Local node: default settings">
```bash
wardend query bank balances shulgin
```
</TabItem>
<TabItem value="local-custom" label="Local node: custom settings">
```bash
wardend query bank balances my-key-name
```
</TabItem>
</Tabs>

### Option 2. Connect to Chiado

1. If you haven't yet, [install Go](https://golang.org/doc/install) 1.22.3 or later and [just](https://github.com/casey/just) 1.34.0 or later.

## 1. Create a CosmWasm project
2. Clone the repository with Warden source code. Then build the binary and initialize the chain home folder:

```bash
git clone --depth 1 --branch v0.5.2 https://github.com/warden-protocol/wardenprotocol
cd wardenprotocol
just wardend build
just wardend install
wardend init my-chain-moniker
```

3. Create a new key:

```bash
wardend keys add my-key-name
```

4. Write down the **mnemonic phrase** and the **address** of the new account. You'll need this information to interact with the chain and restore the account.

:::warning
The seed phrase is the only way to restore your keys. Losing it can result in the irrecoverable loss of WARD tokens.
:::

:::tip
You can always check your public address by running this command:

```bash
wardend keys show my-key-name --address
```
:::

5. Fund your key using [Chiado faucet](https://faucet.chiado.wardenprotocol.org) and the public address obtained in the previous step.

6. Check your balance. Here and in other commands, you need to add the `--node` flag with an RPC URL for connecting to Chiado.

```bash
wardend query bank balances my-key-name --node https://rpc.chiado.wardenprotocol.org:443
```

## 2. Create a CosmWasm project

Create a new CosmWasm project template:

Expand All @@ -59,7 +118,7 @@ cargo generate --git https://github.com/CosmWasm/cw-template.git --name hello-wo
cd hello-world
```

## 2. Modify the contract code
## 3. Modify the contract code

Now you need to modify files in the `/src` directory as shown in the steps below.

Expand Down Expand Up @@ -130,11 +189,6 @@ Now you need to modify files in the `/src` directory as shown in the steps below
#[returns(String)]
GetGreeting {},
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alijnmerchant21 It looks like this part of the code isn't used anywhere else, so I deleted it. I checked the code after that and was able to deploy the contract

#[cw_serde]
pub struct GetCountResponse {
pub count: i32,
}
```

2. Open the `helpers.rs` file and replace its contents with this code:
Expand Down Expand Up @@ -171,7 +225,7 @@ Now you need to modify files in the `/src` directory as shown in the steps below
}
```

## 3. Compile the contract
## 4. Compile the contract

To compile the contract, run the following from the `hellow-world` directory:

ijonele marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -181,7 +235,7 @@ cargo wasm

The contract should be compiled without any errors.

## 4. Optimize the code
## 5. Optimize the code

Now you need to optimize your compiled Wasm code:

Expand All @@ -190,18 +244,12 @@ wasm-opt -Os -o target/wasm32-unknown-unknown/release/hello_world.wasm \
target/wasm32-unknown-unknown/release/hello_world.wasm
```

## 5. Run the chain
## 6. Store the contract on-chain

If your local chain isn't running, execute this command in a separate terminal window:

```bash
wardend start
```
If you're deploying on a local chain, make sure it's running. You can start your chain by running `wardend start` in a separate terminal window.

## 6. Store the contract on-chain
To store your contract on-chain, run the command below. Specify your key name from [Step 1](#1-prepare-the-chain) in the `--from` flag, also set the chain ID.

To store your contract on the Warden chain, run the command below. Specify your key name from [Prerequisites](#prerequisites) in the `--from` flag (typically `shulgin`), also set the chain ID.

<Tabs>
<TabItem value="default" label="Default node settings">
```bash
Expand All @@ -225,21 +273,38 @@ wardend tx wasm store target/wasm32-unknown-unknown/release/hello_world.wasm \
--chain-id chain_123-1
```
</TabItem>
<TabItem value="chiado" label="Chiado">
```bash
wardend tx wasm store target/wasm32-unknown-unknown/release/hello_world.wasm \
--from my-key-name \
--gas auto \
--gas-adjustment 1.3 \
--gas-prices 100000000000award \
-y \
--chain-id chain_123-1 \
--node https://rpc.chiado.wardenprotocol.org:443
ijonele marked this conversation as resolved.
Show resolved Hide resolved
```
</TabItem>
</Tabs>

The transaction should be successful without any errors.

:::tip
If you used a `just` script or a devnet snapshot to run your node, you can omit the `--chain-id` flag in this and the following commands.
:::

## 7. Get the code ID

Get the code ID that indentifies your Wasm code:
Get the code ID that identifies your Wasm code:

<Tabs>
ijonele marked this conversation as resolved.
Show resolved Hide resolved
<TabItem value="local" label="Local chain">
```bash
wardend query wasm list-code
```
</TabItem>
<TabItem value="chiado" label="Chiado">
```bash
wardend query wasm list-code --node https://rpc.chiado.wardenprotocol.org:443
```
</TabItem>
</Tabs>

Note down `code_id` from the output.

Expand Down Expand Up @@ -277,6 +342,20 @@ wardend tx wasm instantiate 1 '{}' \
--chain-id chain_123-1
```
</TabItem>
<TabItem value="chiado" label="Chiado">
```bash
wardend tx wasm instantiate 1 '{}' \
--from my-key-name \
--label "Hello World" \
--gas auto \
--gas-adjustment 1.3 \
--gas-prices 100000000000award \
--no-admin \
-y \
--chain-id chain_123-1 \
--node https://rpc.chiado.wardenprotocol.org:443
```
</TabItem>
</Tabs>


Expand Down Expand Up @@ -317,6 +396,18 @@ wardend tx wasm execute my-contract-address '{"say_hello":{}}' \
--chain-id chain_123-1
```
</TabItem>
<TabItem value="chiado" label="Chiado">
```bash
wardend tx wasm execute my-contract-address '{"say_hello":{}}' \
--from my-key-name \
--gas auto \
--gas-adjustment 1.3 \
--gas-prices 100000000000award \
-y \
--chain-id chain_123-1 \
--node https://rpc.chiado.wardenprotocol.org:443
```
</TabItem>
</Tabs>


Expand Down
Loading
Loading