Skip to content

Commit

Permalink
x/warden (#1122)
Browse files Browse the repository at this point in the history
* added iwarden docs, did a restructure in the section

* a minor fix

* small fixes in the iwarden reference

* Add category for x warden

* Add space

* Add spaces

* rename

* Minor fixes

* Add keys

* Only add code snippets

Remove o/p to reduce overall length of tutorial

* Add code snippet for - Update space, Add space owner, Remove space owner

* Add CLI command  for - Update space, Add space owner, Remove space owner

* Minor fixes

* Add code snippet + CLI command for - Query key, Query Key by ID, Query key by Space ID and Update Key

* Shuffle

* Rename

* Rename

* Rename

* Shuffle

* Add keychain structure

* fixed broken links

* Minor fixes

* Add keyrequest structure

* cleanup

* Add signature structure

* Add preq

* Update space with preq

* Update keys with preq

* Minor fix

* Update keychain with preq

* Update keyrequest with preq

* Update signaturerequest with preq

* Add code for keychain

* Add code for keyrequest

* Add code for keychain

* Minor update

* Add code for signature-request

* Minor update

* edited precomile docs

* edited precomile docs

---------

Co-authored-by: Margarita Skomorokh <ijonele@gmail.com>
  • Loading branch information
alijnmerchant21 and ijonele authored Dec 5, 2024
1 parent 19a528f commit fae2674
Show file tree
Hide file tree
Showing 23 changed files with 2,417 additions and 46 deletions.
11 changes: 11 additions & 0 deletions docs/developer-docs/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"position": 4,
"label": "Precompiles reference",
"collapsible": true,
"collapsed": false,
"link": {
"type": "generated-index",
"title": "Precompiles reference"
},
"customProps": {}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"position": 2,
"position": 3,
"label": "Deploy smart contracts on Warden",
"collapsible": true,
"collapsed": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,16 +283,16 @@ Here are the key points of this contract:

Before you start, do the following:

- If you wish to learn the basics, follow this guide: [Deploy a WASM contract](deploy-a-wasm-contract).
- Install Rust and set up the CosmWasm environment, as shown in [the guide](deploy-a-wasm-contract#prerequisites).
- If you wish to learn the basics, follow this guide: [Deploy a WASM contract](../deploy-smart-contracts-on-warden/deploy-a-wasm-contract).
- Install Rust and set up the CosmWasm environment, as shown in [the guide](../deploy-smart-contracts-on-warden/deploy-a-wasm-contract#prerequisites).
- For interacting with the node, [install Go](https://go.dev/doc/install) 1.22.3 or later and [just](https://github.com/casey/just) 1.34.0 or later.
- Obtain some AXL tokens in the Axelar network.

### 2.1. Create a WASM contract

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#2-create-a-cosmwasm-project).
1. Create a CosmWasm project. You can [use a template](../deploy-smart-contracts-on-warden/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#2-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-smart-contracts-on-warden/deploy-a-wasm-contract#2-create-a-cosmwasm-project), just update the existing files.

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#4-compile-the-contract) and [optimize](deploy-a-wasm-contract#5-optimize-the-code) your contract.
Now you can [compile](../deploy-smart-contracts-on-warden/deploy-a-wasm-contract#4-compile-the-contract) and [optimize](../deploy-smart-contracts-on-warden/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 @@ -428,3 +428,8 @@ In the output, you should see this: `data: Hello, World!`
If you encounter any issues, please reach out to us in [Discord](https://discord.com/invite/wardenprotocol) or [Twitter](https://twitter.com/wardenprotocol).

Happy coding! 🚀

## Next steps

After deploying a basic WASM smart contract, you can [deploy a cross-chain app using GMP](deploy-a-cross-chain-app).

Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ In the following steps, we're going to deploy this contract without modification
```
:::warning
In production, never store private keys directly in environment variables. Consider using encrypted keystores or secure key management solutions.
In production, never store private keys directly in environment variables. Consider using encrypted keystores or secure key management solutions like `env`.
:::
1. Export the RPC URL. Specify the standard localhost address or Chiado's EVM endpoint:
Expand Down Expand Up @@ -219,31 +219,29 @@ In the following steps, we're going to deploy this contract without modification
Transaction hash: 0x38c67c5bd92589ec6e31c2204a577e4c8d365099daad1382ff2596893b405249
```
4. Note down the value returned as `Deployed to` – that's your **contract address**.

## 5. Verify the deployment

1. Export your contract address as a variable by running the following command. Specify the address returned in the previous step.
4. Note down the value returned as `Deployed to` – that's your **contract address**. Export it as a variable:

```bash
export CONTRACT_ADDRESS=my-contract-address
```

2. Verify that the contract has been deployed on this address:
## 5. Verify the deployment

```bash
cast code $CONTRACT_ADDRESS --rpc-url $RPC_URL
```
To verify that the contract has been deployed on the address from the previous step, run this:

:::note
The [`cast code`](https://book.getfoundry.sh/reference/cast/cast-code) Foundry command allows you to get the bytecode of a contract.
:::
```bash
cast code $CONTRACT_ADDRESS --rpc-url $RPC_URL
```

You'll see an output similar to the following:
:::note
The [`cast code`](https://book.getfoundry.sh/reference/cast/cast-code) Foundry command allows you to get the bytecode of a contract.
:::

```bash
0x6080604052348015600f57600080fd5b5060043610603c5760003560e01c80633fb5c1cb1460415780638381f58a146053578063d09de08a14606d575b600080fd5b6051604c3660046083565b600055565b005b605b60005481565b60405190815260200160405180910390f35b6051600080549080607c83609b565b9190505550565b600060208284031215609457600080fd5b5035919050565b60006001820160ba57634e487b7160e01b600052601160045260246000fd5b506001019056fea26469706673582212201c88540d2739bb0e4f6179275ef6ff63cf1c34ed53189691f9dd0033f4382a0264736f6c634300081c0033
```
You'll see an output similar to the following:
```bash
0x6080604052348015600f57600080fd5b5060043610603c5760003560e01c80633fb5c1cb1460415780638381f58a146053578063d09de08a14606d575b600080fd5b6051604c3660046083565b600055565b005b605b60005481565b60405190815260200160405180910390f35b6051600080549080607c83609b565b9190505550565b600060208284031215609457600080fd5b5035919050565b60006001820160ba57634e487b7160e01b600052601160045260246000fd5b506001019056fea26469706673582212201c88540d2739bb0e4f6179275ef6ff63cf1c34ed53189691f9dd0033f4382a0264736f6c634300081c0033
```
## 6. Interact with the contract
Expand Down Expand Up @@ -337,7 +335,7 @@ Now you can interact with the contract: adjust and increment the counter number.

## Troubleshooting

- If your transaction fails, try the following:
If your transaction fails, try the following:

- Verify that your private key is correct. See [Step 1](#1-prepare-the-chain).
- Make sure you have enough funds in your account, as shown in [Step 1](#1-prepare-the-chain). If funds are insufficient, you may need to [run a local chain](/operate-a-node/run-a-local-chain) from scratch or use [Chiado faucet](https://faucet.chiado.wardenprotocol.org).
Expand All @@ -346,3 +344,13 @@ Now you can interact with the contract: adjust and increment the counter number.
If you encounter any other issues, please reach out to us in [Discord](https://discord.com/invite/wardenprotocol) or [Twitter](https://twitter.com/wardenprotocol).

Happy coding! 🚀

## Next steps

After deploying a basic EVM smart contract, start using Warden precompiles to call Warden modules in your contract. This will allow you to access Warden-specific features such as managing Spaces and Keychains, creating Rules, getting data from oracles, and so on.

See the following sections:

- [Call Warden modules in your contract](/category/interact-with-warden-modules)
- [Solidity precompiles](/category/precompiles)

Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ sidebar_position: 4

# Useful links

## Overview

The main part of any Omnichain Application is a smart contract that allows signing transactions and messages at any destination chain. This section contains links to resources you can use for deploying Omnichain Contracts of two types:

- **EVM** contracts written in **Solidity**, charged by Evmos
- **CosmWasm** contracts written in **Rust**

## EVM contracts

- **`x/evm` resources**
Expand Down
2 changes: 1 addition & 1 deletion docs/developer-docs/docs/build-an-app/examples-of-oapps.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 5
sidebar_position: 2
---

# Examples of OApps
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"position": 4,
"label": "Interact with Warden modules",
"collapsible": true,
"collapsed": false,
"link": {
"type": "generated-index",
"title": "Interact with Warden modules"
},
"customProps": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
sidebar_position: 1
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Get started

## Overview

This guide shows how to prepare an EVM smart contract for interacting with [Warden Protocol modules](/category/warden-protocol-modules).

You're going to call modules from your contract by using functions from the available [Warden precompiles](/category/precompiles).

## Prerequisites

Before you start, complete the following prerequisites:

1. [Install Foundry](https://book.getfoundry.sh/getting-started/installation) by running this command:

```bash
curl -L https://foundry.paradigm.xyz | bash \
foundryup
```

2. [Prepare the chain](../deploy-smart-contracts-on-warden/deploy-an-evm-contract#1-prepare-the-chain), setting up your private key.

## 1. Create a project and contract

1. Initialize a new Foundry project and navigate to its directory:

```bash
forge init warden-smart-contract --no-commit
cd warden-smart-contract
```

2. In the `/src` directory, create a new contract named `Warden.sol`.

3. Finally, prepare the contract code. You can use code samples from the following sections:

- [Interact with x/warden](/category/interact-with-xwarden)

## 2. Compile and deploy the contract

1. Export your private key and the RPC URL as environmental variables:

<Tabs>
<TabItem value="local" label="Local node">
```bash
export PRIVATE_KEY=my-private-key
export RPC_URL=http://127.0.0.1:8545
```
</TabItem>
<TabItem value="chiado" label="Chiado">
```bash
export PRIVATE_KEY=my-private-key
export RPC_URL=https://evm.chiado.wardenprotocol.org
```
</TabItem>
</Tabs>

:::warning
In production, never store private keys directly in environment variables. Consider using encrypted keystores or secure key management solutions like `.env`.
:::

2. Compile your contract using Foundry:

```bash
forge build
```

3. Deploy the contract:

```bash
forge create --rpc-url $RPC_URL --private-key $PRIVATE_KEY src/Warden.sol:WardenContract
```

4. Export your contract address returned in `Deployed to`:

```
export CONTRACT_ADDRESS=my-contract-address
```

5. Verify the deployment:

```bash
cast code $CONTRACT_ADDRESS --rpc-url $RPC_URL
```

## Next steps

- To dive deeper and find code samples for each function from Warden precompiles, see the following guides:
- [Interact with x/warden](/category/interact-with-xwarden)
- *Other modules: coming soon.*
- For an overview of the functions, refer to the [Precompiles](/category/precompiles) section.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"position": 2,
"label": "Interact with x/warden",
"collapsible": true,
"collapsed": true,
"link": {
"type": "generated-index",
"title": "Interact with x/warden"
},
"customProps": {}
}
Loading

0 comments on commit fae2674

Please sign in to comment.