1- ### Smart Contract in ink!
1+ ### Smart Contracts using XCM
22
33## Table of Contents
44
55* [ Setup] ( #setup )
66 * [Setup Docker Container](#setup-container)
77 * [Run Cargo Contracts Node in Docker Container](#run-cargo-contracts-node)
88* Build & Upload
9- * [**Quickstart** Build & Upload ink! Rust Flipper Smart Contract to Local Testnet (using Cargo Contract)](#quick-build-upload)
10- * [Build & Upload ink! Rust Flipper Smart Contract to Local Testnet (using Cargo Contract)](#build-upload)
11- * [Build & Upload ink! Rust Flipper Smart Contract to Local Testnet (using Swanky CLI)](#build-upload-swanky)
9+ * [**Quickstart** Build & Upload "Flipper" ink! Rust Smart Contract to Local Testnet (using Cargo Contract)](#quick-build-upload)
10+ * [**Quickstart** Build & Upload "Basic Contract Caller" ink! Rust Smart Contract to Local Testnet (using Cargo Contract)](#quick-basic-contract-caller)
11+ * [**Quickstart** Build & Upload "IPSP22" ink! Rust Smart Contract to Local Testnet (using Cargo Contract)](#quick-ipsp22)
12+ * [**Quickstart** Build & Upload "Unnamed" ink! Rust Smart Contract to Local Testnet (using Cargo Contract)](#quick-unnamed)
13+ * [Build & Upload Moonbeam VRF Randomness Precompile Solidity Smart Contract to Moonbase Alpha Testnet (using Truffle)](#moonbase-vrf)
14+ * [Build & Upload Chainlink VRFD20 Randomness Solidity Smart Contract to Ethereum Sepolia Testnet (using Truffle)](#vrfd20)
15+ * [Build & Upload "Flipper" ink! Rust Smart Contract to Local Testnet (using Cargo Contract)](#build-upload)
16+ * [Build & Upload "Flipper" ink! Rust Smart Contract to Local Testnet (using Swanky CLI)](#build-upload-swanky)
1217* Interact
1318 * [Interact with ink! Python Smart Contract](#interact-python)
1419 * [Interact with ink! Rust Flipper Smart Contract using Polkadot.js API](#interact-polkadot-js-flipper)
@@ -114,6 +119,7 @@ substrate-contracts-node --version
114119``` bash
115120SCN_PORT=$( docker exec -it ink lsof -ti:30333) && \
116121docker exec -it ink echo $( kill -9 $SCN_PORT ) && \
122+ docker exec -it ink /app/docker/reset.sh && \
117123docker exec -it ink /app/docker/quickstart.sh
118124```
119125
@@ -125,6 +131,7 @@ docker exec -it ink /app/docker/quickstart.sh
125131 ```
126132 * Run quickstart
127133 ```bash
134+ ./docker/reset.sh
128135 ./docker/quickstart.sh
129136 ```
130137
@@ -135,6 +142,66 @@ docker exec -it ink /app/docker/quickstart.sh
135142 * Redeploys the Flipper contract
136143 * Interacts with the Flipper contract
137144
145+ ### ** Demo Quickstart** Build & Upload ink! Rust "Basic Contract Caller" Smart Contract to Local Testnet (using Cargo Contract) <a id =" quick-basic-contract-caller " ></a >
146+
147+ #### Run from shell inside Docker container
148+
149+ * Enter shell of Docker container
150+ ```bash
151+ docker exec -it ink /bin/bash
152+ ```
153+ * Run in terminal tab 1
154+ ```bash
155+ ./docker/reset.sh
156+ ```
157+ * Run in terminal tab 2
158+ ```
159+ ./docker/quickstart-basic-contract-caller.sh
160+ ```
161+
162+ ### ** Demo Quickstart** Build & Upload ink! Rust "IPSP22" Smart Contract to Local Testnet (using Cargo Contract) <a id =" quick-ipsp22 " ></a >
163+
164+ #### Run from shell inside Docker container
165+
166+ * Enter shell of Docker container
167+ ```bash
168+ docker exec -it ink /bin/bash
169+ ```
170+ * Run in terminal tab 1
171+ ```bash
172+ ./docker/reset.sh
173+ ```
174+ * Run in terminal tab 2
175+ ```bash
176+ cd /app
177+ ./docker/quickstart-ipsp22.sh
178+ ```
179+
180+ ### ** Demo Quickstart** Build & Upload ink! Rust "Unnamed" Smart Contract to Local Testnet (using Cargo Contract) <a id =" quick-unnamed " ></a >
181+
182+ #### Run from shell inside Docker container
183+
184+ * Enter shell of Docker container
185+ ```bash
186+ docker exec -it ink /bin/bash
187+ ```
188+ * Run in terminal tab 1
189+ ```bash
190+ ./docker/reset.sh
191+ ```
192+ * Run in terminal tab 2
193+ ````
194+ ./docker/quickstart-unnamed.sh
195+ ```
196+
197+ ### Build & Upload Moonbeam VRF Randomness Precompile Solidity Smart Contract to Moonbase Alpha Testnet (using Truffle) <a id =" moonbase-vrf " ></a >
198+
199+ * Follow the instructions in the [ VRF example README] ( ./dapps/evm2/randomness/README.md )
200+
201+ ### Build & Upload Chainlink VRFD20 Randomness Solidity Smart Contract to Ethereum Sepolia Testnet (using Truffle) <a id =" vrfd20 " ></a >
202+
203+ * Follow the instructions in the [ VRF20 example README] ( ./dapps/evm2/randomness/README.md )
204+
138205### Build & Upload ink! Rust Flipper Smart Contract to Local Testnet (using Cargo Contract) <a id =" build-upload " ></a >
139206
140207* Create Rust project with template
@@ -249,12 +316,12 @@ Note: Try `rustup update` if you face error
249316
250317Local Testnet
251318``` bash
252- swanky contract deploy flipper --account alice -g 100000000000 -a true
319+ swanky contract deploy flipper --account alice -g 1000000000000 -a true
253320```
254321
255322Shibuya Testnet
256323``` bash
257- swanky contract deploy flipper --account alice --gas 100000000000 --args true --network shibuya
324+ swanky contract deploy flipper --account alice --gas 1000000000000 --args true --network shibuya
258325```
259326Copy paste the contract address.
260327
@@ -359,8 +426,8 @@ cargo contract call \
359426* Note: If you don' t build in "debug" mode with `cargo contract build ...` instead of `cargo contract build --release ...` and you run it using **dry run** by running extra options like the following, or if you execute as a transaction, then you won' t be able to see node terminal debug logs like ` tokio-runtime-worker runtime::contracts Execution finished with debug buffer...` from your use of ` ink::env::debug_println!` in the smart contract
360427` ` ` bash
361428 --skip-dry-run \
362- --gas 100000000000 \
363- --proof-size 100000000000
429+ --gas 1000000000000 \
430+ --proof-size 1000000000000
364431` ` `
365432
366433# ## Tips Docker Commands <a id="tips-docker"></a>
@@ -424,6 +491,9 @@ docker buildx rm --all-inactive
424491 * Contracts pallet allows deployment and execution of WebAssembly-based smart contracts
425492 * What trait do smart contract accounts used in the Contracts pallet of Substrate extend?
426493 * ` Currency` trait
494+ * How to resolve ` ERROR: This contract has already been uploaded with code hash`
495+ * It may be because you ran a Substrate contract node on your host machine and then tried running another one in your Docker container. So it may be necessary to run ` kill -9 $( lsof -ti:30333) ` on
496+ both the host machine and inside the Docker container. Or just restart Docker.
427497
428498
429499* Link
0 commit comments