Skip to content

Commit 5f74877

Browse files
authored
Merge pull request #16 from ltfschoen/unnamed
Unnamed
2 parents abccbe7 + b724f57 commit 5f74877

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+4683
-222
lines changed

Cargo.lock

Lines changed: 703 additions & 193 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ exclude = []
44

55
members = [
66
"dapps/ink-rust/wasm-flipper/contract/flipper",
7+
"dapps/ink-rust/IPSP22/contract/IPSP22",
8+
"dapps/xcm/unnamed",
9+
"dapps/basic_contract_caller",
710
]

README.md

Lines changed: 78 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
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
115120
SCN_PORT=$(docker exec -it ink lsof -ti:30333) && \
116121
docker exec -it ink echo $(kill -9 $SCN_PORT) && \
122+
docker exec -it ink /app/docker/reset.sh && \
117123
docker 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

250317
Local 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

255322
Shibuya 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
```
259326
Copy 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
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Ignore build artifacts from the local tests sub-crate.
2+
/target/
3+
4+
# Ignore backup files creates by cargo fmt.
5+
**/*.rs.bk
6+
7+
# Remove Cargo.lock when creating an executable, leave it for libraries
8+
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
9+
Cargo.lock
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[package]
2+
name = "basic_contract_caller"
3+
version = "4.2.0"
4+
authors = ["Parity Technologies <[email protected]>"]
5+
edition = "2021"
6+
publish = false
7+
8+
[dependencies]
9+
ink = { version = "4.2", default-features = false }
10+
11+
scale = { package = "parity-scale-codec", version = "3.5.0", default-features = false, features = ["derive"] }
12+
scale-info = { version = "2.7", default-features = false, features = ["derive"], optional = true }
13+
14+
# Note: We **need** to specify the `ink-as-dependency` feature.
15+
#
16+
# If we don't we will end up with linking errors!
17+
other_contract = { path = "other_contract", default-features = false, features = ["ink-as-dependency"] }
18+
19+
[dev-dependencies]
20+
ink_e2e = { version = "4.2.0" }
21+
22+
[lib]
23+
path = "lib.rs"
24+
25+
[features]
26+
default = ["std"]
27+
std = [
28+
"ink/std",
29+
"scale/std",
30+
"scale-info/std",
31+
32+
# Note: The metadata generation step requires `std`. If we don't specify this the metadata
33+
# generation for our contract will fail!
34+
"other_contract/std",
35+
]
36+
ink-as-dependency = []
37+
e2e-tests = []

0 commit comments

Comments
 (0)