3
3
CosmWasm is a smart contracting platform built for the Cosmos
4
4
ecosystem by making use of [ WebAssembly] ( https://webassembly.org ) (Wasm)
5
5
to build smart contracts for Cosmos-SDK. In this tutorial, we will be
6
- exploring how to integrate CosmWasm with Celestia's
7
- [ data availability layer] ( https://docs.celestia.org/concepts/how-celestia-works/data-availability-layer )
8
- using Rollkit.
6
+ exploring how to integrate CosmWasm with local DA layer using Rollkit.
9
7
10
8
<!-- markdownlint-disable MD033 -->
11
9
<script setup >
@@ -17,40 +15,25 @@ import Callout from '../.vitepress/components/callout.vue'
17
15
:::
18
16
<!-- markdownlint-enable MD033 -->
19
17
20
- ::: warning
21
- The script for this tutorial is built for Celestia's
22
- [ Mocha testnet] ( https://docs.celestia.org/nodes/mocha-testnet ) .
23
- :::
24
-
25
- You can learn more about CosmWasm [ here] ( https://docs.cosmwasm.com/docs/ ) .
26
-
27
18
The smart contract we will use for this tutorial is one provided by
28
19
the CosmWasm team for Nameservice purchasing.
29
20
30
21
You can check out the contract [ here] ( https://github.com/InterWasm/cw-contracts/tree/main/contracts/nameservice ) .
31
22
32
23
How to write the Rust smart contract for Nameservice is outside the scope of
33
- this tutorial. In the future we will add more tutorials for writing CosmWasm
34
- smart contracts for Celestia.
24
+ this tutorial.
35
25
36
26
## 💻 CosmWasm dependency installations {#dependencies}
37
27
38
- ### 🛠️ Environment setup {#environment}
39
-
40
- For this tutorial, we will be using ` curl ` and ` jq ` as helpful
41
- tools. You can follow the guide on installing them
42
- [ here] ( https://docs.celestia.org/nodes/environment/#-install-wget-and-jq ) .
28
+ ### 🏃 Golang {#install-go}
43
29
44
- ### 🏃 Golang dependency {# install-golang}
30
+ For this tutorial, we will need ` go ` and ` jq ` installed on your machine. You can install them by running our script:
45
31
46
- The Golang version used for this tutorial is v1.19+
47
-
48
- You can install Golang
49
- by following our tutorial [ here] ( https://docs.celestia.org/nodes/environment#install-golang ) .
50
-
51
- ### 🦀 Rust installation {#install-rust}
32
+ ``` bash
33
+ curl -sSL https://rollkit.dev/install-go.sh | bash -s go1.22.3
34
+ ```
52
35
53
- #### 🔨 Rustup {#rustup }
36
+ ### 🦀 Rust {#install-rust }
54
37
55
38
First, before installing Rust, you would need to install ` rustup ` .
56
39
@@ -118,7 +101,7 @@ Find the right instructions specific for
118
101
119
102
Here, we are going to pull down the `wasmd` repository and replace CometBFT
120
103
with Rollkit. Rollkit is a drop-in replacement for CometBFT that allows
121
- Cosmos-SDK applications to connect to Celestia ' s data availability network.
104
+ Cosmos-SDK applications to connect to data availability (DA) network.
122
105
123
106
```bash
124
107
git clone https://github.com/CosmWasm/wasmd.git
@@ -150,22 +133,16 @@ make install
150
133
You will have to install `gcc` if you are trying it on a clean linux vm.
151
134
:::
152
135
153
- # ## ✨ Celestia node {#celestia-node}
154
-
155
- You will need a light node running with test tokens on
156
- [Mocha testnet](https://docs.celestia.org/nodes/mocha-testnet) in order
157
- to complete this tutorial. Complete [the tutorial](https://docs.celestia.org/developers/node-tutorial)
158
- and start up your node.
136
+ ### ✨ Local DA node {#local-da-node}
159
137
160
- Be sure you have initialized your node before trying to start it.
161
- Your start command should look similar to:
138
+ You will need a local-da node running in order to complete this tutorial. To start it, run:
162
139
163
- < ! -- markdownlint-disable MD013 -->
164
140
```bash
165
- celestia light start --core.ip rpc-mocha.pops.one --p2p.network mocha
141
+ curl -sSL https://rollkit.dev/install-local-da.sh | bash -s v0.2.0
166
142
```
167
143
168
- # # 🌌 Setting up your environment for CosmWasm on Celestia {#setting-up-environment-on-celestia}
144
+
145
+ ## 🌌 Setting up your environment for CosmWasm on local-da {#setting-up-environment-on-local-da}
169
146
170
147
Now the `wasmd` binary is built, we need to setup a local network
171
148
that communicates between `wasmd` and Rollkit.
@@ -197,10 +174,6 @@ bash init.sh
197
174
198
175
With that, we have kickstarted our `wasmd` network!
199
176
200
- View your rollup by
201
- [finding your namespace or account Celenium](https://celenium.io).
202
-
203
- [View the example rollup' s namespace on Celenium](https://celenium.io/namespace/000000000000000000000000000000000000000008e5f679bf7116cb).
204
177
205
178
### 💠 Optional: see what' s inside the script {# view-script}
206
179
@@ -282,28 +255,25 @@ Run the following in the `~/cw-contracts/contracts/nameservice` directory:
282
255
283
256
<!-- markdownlint-disable MD013 -->
284
257
```bash [AMD Machines]
285
- TX_HASH=$(wasmd tx wasm store artifacts/cw_nameservice.wasm --from celeswasm -key --keyring-backend test --chain-id celeswasm --gas-prices 0.025uwasm --gas auto --gas-adjustment 1.3 --node http://127.0.0.1:36657 --output json -y | jq -r ' .txhash' ) && echo $TX_HASH
258
+ TX_HASH=$(wasmd tx wasm store artifacts/cw_nameservice.wasm --from localwasm -key --keyring-backend test --chain-id localwasm --gas-prices 0.025uwasm --gas auto --gas-adjustment 1.3 --node http://127.0.0.1:36657 --output json -y | jq -r ' .txhash' ) && echo $TX_HASH
286
259
```
287
260
<!-- markdownlint-enable MD013 -->
288
261
289
262
<!-- markdownlint-disable MD013 -->
290
263
```bash [ARM Machines]
291
- TX_HASH=$(wasmd tx wasm store artifacts/cw_nameservice-aarch64.wasm --from celeswasm -key --keyring-backend test --chain-id celeswasm --gas-prices 0.025uwasm --gas auto --gas-adjustment 1.3 --node http://127.0.0.1:36657 --output json -y | jq -r ' .txhash' ) && echo $TX_HASH
264
+ TX_HASH=$(wasmd tx wasm store artifacts/cw_nameservice-aarch64.wasm --from localwasm -key --keyring-backend test --chain-id localwasm --gas-prices 0.025uwasm --gas auto --gas-adjustment 1.3 --node http://127.0.0.1:36657 --output json -y | jq -r ' .txhash' ) && echo $TX_HASH
292
265
293
266
:::
294
267
295
- This will get you the transaction hash for the smart contract deployment. Given
296
- we are using Rollkit, there will be a delay on the transaction being included
297
- due to Rollkit waiting on Celestia' s data availability layer to confirm the block
298
- has been included before submitting a new block.
268
+ This will get you the transaction hash for the smart contract deployment.
299
269
300
270
::: danger
301
271
If you run into errors with variables on the previous command,
302
272
or commands in the remainder of the tutorial, cross-reference
303
273
the variables in the command with the variables in the `init.sh` script.
304
274
:::
305
275
306
- # # 🌟 Contract interaction on CosmWasm with Celestia {#contract-interaction-on-celestia }
276
+ ## 🌟 Contract interaction on CosmWasm {#contract-interaction-on-local-da }
307
277
<!-- markdownlint-disable MD013 -->
308
278
309
279
In the previous steps, we have stored out contract' s tx hash in an
@@ -312,13 +282,9 @@ environment variable for later use.
312
282
The following guide will show you how to deploy and interact with a contract using CLI.
313
283
For scripting using Rust, you can use [cw-orchestrator](/guides/cw-orch.md).
314
284
315
- Because of the longer time periods of submitting transactions via Rollkit
316
- due to waiting on Celestia' s data availability layer to confirm block inclusion,
317
- we will need to query our tx hash directly to get information about it.
318
-
319
285
# ## 🔎 Contract querying {#contract-querying}
320
286
321
- Let ' s start by querying our transaction hash for its code ID:
287
+ Now, let ' s query our transaction hash for its code ID:
322
288
323
289
```bash
324
290
CODE_ID=$(wasmd query tx --type=hash $TX_HASH --node http://127.0.0.1:36657 --output json | jq -r ' .events[-1].attributes[1].value' )
@@ -350,7 +316,7 @@ is `100uwasm` and `transfer_price` is `999uwasm`.
350
316
351
317
` ` ` bash
352
318
INIT=' {"purchase_price":{"amount":"100","denom":"uwasm"},"transfer_price":{"amount":"999","denom":"uwasm"}}'
353
- wasmd tx wasm instantiate $CODE_ID " $INIT " --from celeswasm -key --keyring-backend test --label " name service" --chain-id celeswasm --gas-prices 0.025uwasm --gas auto --gas-adjustment 1.3 -y --no-admin --node http://127.0.0.1:36657
319
+ wasmd tx wasm instantiate $CODE_ID " $INIT " --from localwasm -key --keyring-backend test --label " name service" --chain-id localwasm --gas-prices 0.025uwasm --gas auto --gas-adjustment 1.3 -y --no-admin --node http://127.0.0.1:36657
354
320
` ` `
355
321
356
322
# ## 📄 Contract interaction {#contract-interaction}
@@ -393,7 +359,7 @@ Now, let's register a name to the contract for our wallet address:
393
359
394
360
```bash
395
361
REGISTER=' {" register" :{" name" :" fred" }}'
396
- wasmd tx wasm execute $CONTRACT "$REGISTER" --amount 100uwasm --from celeswasm -key --chain-id celeswasm --gas-prices 0.025uwasm --gas auto --gas-adjustment 1.3 --node http://127.0.0.1:36657 --keyring-backend test -y
362
+ wasmd tx wasm execute $CONTRACT "$REGISTER" --amount 100uwasm --from localwasm -key --chain-id localwasm --gas-prices 0.025uwasm --gas auto --gas-adjustment 1.3 --node http://127.0.0.1:36657 --keyring-backend test -y
397
363
```
398
364
399
365
Your output will look similar to below:
@@ -436,4 +402,4 @@ You'll see the owner's address in a JSON response:
436
402
` ` `
437
403
438
404
With that, we have instantiated and interacted with the CosmWasm nameservice
439
- smart contract using Celestia !
405
+ smart contract on our local DA network using Rollkit !
0 commit comments