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

Unnamed #16

Merged
merged 60 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
bb6a407
add unnamed using flipper template
ltfschoen Jun 10, 2023
231d7ae
wip
ltfschoen Jun 11, 2023
8fdf3bb
wip
ltfschoen Jun 11, 2023
3faf53e
resolve some errors
ltfschoen Jun 11, 2023
e5e7720
fix all errors
ltfschoen Jun 12, 2023
14b04a5
use raw bytes instead of hash type so can access length of block hash
ltfschoen Jun 12, 2023
7d035fe
save and emit entropy of coin1 and coin2
ltfschoen Jun 12, 2023
f1b5c55
wip stuck stubbing blocknumber from ink environment
ltfschoen Jun 13, 2023
56aaa29
use set_block_number from pr to upstream working
ltfschoen Jun 13, 2023
10a08f8
fix contracts using String but already uploaded error
ltfschoen Jun 15, 2023
88782c0
working. allow toggle --skip-dry-run with bulk comment
ltfschoen Jun 15, 2023
aeb12bc
add basic_contract_caller from ink-examples
ltfschoen Jun 15, 2023
ed4290e
add basic_contract_caller all working
ltfschoen Jun 16, 2023
931fe20
remove get message from main contract and do not call it generates error
ltfschoen Jun 16, 2023
4217f6b
restore get method in main contract
ltfschoen Jun 16, 2023
455c222
convert to CreateBuilder and CallBuilder but with error when call via…
ltfschoen Jun 16, 2023
e5f449a
fix basic-contract-caller
ltfschoen Jun 17, 2023
5686da3
call via main but no Builder not support tuple return Decode(Error)
ltfschoen Jun 18, 2023
bf4e6f2
fix Decode(Error) caused by assertion failing since call from contrac…
ltfschoen Jun 18, 2023
3433a89
demo handling errors
ltfschoen Jun 19, 2023
75f5370
fix LangError
ltfschoen Jun 19, 2023
4ae3e63
setup moonbeam MyToken template
ltfschoen Jun 20, 2023
39fcd92
ipsp22
ltfschoen Jun 20, 2023
73750e6
update readme and add ipsp22 script
ltfschoen Jun 21, 2023
768361f
add evm example pending astar response
ltfschoen Jun 22, 2023
e98be60
Merge pull request #17 from ltfschoen/moonbeam
ltfschoen Jun 22, 2023
8887442
update precompile but DeploymentError RandonNumber hit a require or r…
ltfschoen Jun 23, 2023
fd5624c
incorporate feedback from moonbuilders
ltfschoen Jun 23, 2023
d68f6d5
fix so only use randomness after instantiated Randomness
ltfschoen Jun 24, 2023
4962720
try use console log
ltfschoen Jun 24, 2023
2f66366
wip errors due to https://github.com/trufflesuite/truffle/issues/3468…
ltfschoen Jun 24, 2023
4df48da
stuck on error ProviderError 32603 calling requestRandomness
ltfschoen Jun 25, 2023
30db35e
StatusError in tx for requestRandomness
ltfschoen Jun 25, 2023
df8ac88
try change to Websocket endpoint but error Web3WSProviderError: Reque…
ltfschoen Jun 26, 2023
84a6508
MethodNotImplementedError: The method you're trying to call is not im…
ltfschoen Jun 26, 2023
49f7632
timeouts
ltfschoen Jun 26, 2023
2efa2e6
works up to getting requestId but still often get error PollingBlockT…
ltfschoen Jun 26, 2023
6d85e28
tests working enough to generate random number
ltfschoen Jun 27, 2023
5b96de4
update readme
ltfschoen Jun 27, 2023
3b01dd0
add vrf template contracts
ltfschoen Jun 27, 2023
fb3d91f
wip Chainlink VRF Sepolia
ltfschoen Jun 27, 2023
2a2cd51
Uncaught Error: invalid 1st argument: block_number value was not vali…
ltfschoen Jun 27, 2023
dd0d6ab
success deploying chainlink VRF to Sepolia
ltfschoen Jun 27, 2023
f1d3067
Merge pull request #20 from ltfschoen/chainlink
ltfschoen Jun 27, 2023
039630f
trying to interact with vrf to play game
ltfschoen Jun 28, 2023
e8992e4
able to get instance of vrf contract
ltfschoen Jun 28, 2023
3a8541b
fix use of correct alchemy key
ltfschoen Jun 28, 2023
5d3b2c3
fix migration, requires min deposit of 1 eth to not error
ltfschoen Jun 29, 2023
34e8cf5
fix use of alchemy but error when creating chainlink subscription to …
ltfschoen Jul 2, 2023
a7a7971
wait a few blocks before get rolled value for player
ltfschoen Jul 2, 2023
79af150
show current error
ltfschoen Jul 2, 2023
991b0cd
wip
ltfschoen Jul 2, 2023
4da18cf
insufficient funds for gas * price + value
ltfschoen Jul 3, 2023
78c4c52
crashes on requestRandomness. fixes error insufficient funds for intr…
ltfschoen Jul 3, 2023
74eca77
wip
ltfschoen Jul 3, 2023
4e136dc
fix vrf
ltfschoen Jul 5, 2023
5dde11b
wip
ltfschoen Jul 6, 2023
0d6b01a
split flipper from moonbase vrf example
ltfschoen Jul 6, 2023
5f827f9
update readme
ltfschoen Jul 6, 2023
b724f57
rename flipper folder to randomness
ltfschoen Jul 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
896 changes: 703 additions & 193 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ exclude = []

members = [
"dapps/ink-rust/wasm-flipper/contract/flipper",
"dapps/ink-rust/IPSP22/contract/IPSP22",
"dapps/xcm/unnamed",
"dapps/basic_contract_caller",
]
86 changes: 78 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
### Smart Contract in ink!
### Smart Contracts using XCM

## Table of Contents

* [Setup](#setup)
* [Setup Docker Container](#setup-container)
* [Run Cargo Contracts Node in Docker Container](#run-cargo-contracts-node)
* Build & Upload
* [**Quickstart** Build & Upload ink! Rust Flipper Smart Contract to Local Testnet (using Cargo Contract)](#quick-build-upload)
* [Build & Upload ink! Rust Flipper Smart Contract to Local Testnet (using Cargo Contract)](#build-upload)
* [Build & Upload ink! Rust Flipper Smart Contract to Local Testnet (using Swanky CLI)](#build-upload-swanky)
* [**Quickstart** Build & Upload "Flipper" ink! Rust Smart Contract to Local Testnet (using Cargo Contract)](#quick-build-upload)
* [**Quickstart** Build & Upload "Basic Contract Caller" ink! Rust Smart Contract to Local Testnet (using Cargo Contract)](#quick-basic-contract-caller)
* [**Quickstart** Build & Upload "IPSP22" ink! Rust Smart Contract to Local Testnet (using Cargo Contract)](#quick-ipsp22)
* [**Quickstart** Build & Upload "Unnamed" ink! Rust Smart Contract to Local Testnet (using Cargo Contract)](#quick-unnamed)
* [Build & Upload Moonbeam VRF Randomness Precompile Solidity Smart Contract to Moonbase Alpha Testnet (using Truffle)](#moonbase-vrf)
* [Build & Upload Chainlink VRFD20 Randomness Solidity Smart Contract to Ethereum Sepolia Testnet (using Truffle)](#vrfd20)
* [Build & Upload "Flipper" ink! Rust Smart Contract to Local Testnet (using Cargo Contract)](#build-upload)
* [Build & Upload "Flipper" ink! Rust Smart Contract to Local Testnet (using Swanky CLI)](#build-upload-swanky)
* Interact
* [Interact with ink! Python Smart Contract](#interact-python)
* [Interact with ink! Rust Flipper Smart Contract using Polkadot.js API](#interact-polkadot-js-flipper)
Expand Down Expand Up @@ -114,6 +119,7 @@ substrate-contracts-node --version
```bash
SCN_PORT=$(docker exec -it ink lsof -ti:30333) && \
docker exec -it ink echo $(kill -9 $SCN_PORT) && \
docker exec -it ink /app/docker/reset.sh && \
docker exec -it ink /app/docker/quickstart.sh
```

Expand All @@ -125,6 +131,7 @@ docker exec -it ink /app/docker/quickstart.sh
```
* Run quickstart
```bash
./docker/reset.sh
./docker/quickstart.sh
```

Expand All @@ -135,6 +142,66 @@ docker exec -it ink /app/docker/quickstart.sh
* Redeploys the Flipper contract
* Interacts with the Flipper contract

### **Demo Quickstart** Build & Upload ink! Rust "Basic Contract Caller" Smart Contract to Local Testnet (using Cargo Contract) <a id="quick-basic-contract-caller"></a>

#### Run from shell inside Docker container

* Enter shell of Docker container
```bash
docker exec -it ink /bin/bash
```
* Run in terminal tab 1
```bash
./docker/reset.sh
```
* Run in terminal tab 2
```
./docker/quickstart-basic-contract-caller.sh
```

### **Demo Quickstart** Build & Upload ink! Rust "IPSP22" Smart Contract to Local Testnet (using Cargo Contract) <a id="quick-ipsp22"></a>

#### Run from shell inside Docker container

* Enter shell of Docker container
```bash
docker exec -it ink /bin/bash
```
* Run in terminal tab 1
```bash
./docker/reset.sh
```
* Run in terminal tab 2
```bash
cd /app
./docker/quickstart-ipsp22.sh
```

### **Demo Quickstart** Build & Upload ink! Rust "Unnamed" Smart Contract to Local Testnet (using Cargo Contract) <a id="quick-unnamed"></a>

#### Run from shell inside Docker container

* Enter shell of Docker container
```bash
docker exec -it ink /bin/bash
```
* Run in terminal tab 1
```bash
./docker/reset.sh
```
* Run in terminal tab 2
````
./docker/quickstart-unnamed.sh
```

### Build & Upload Moonbeam VRF Randomness Precompile Solidity Smart Contract to Moonbase Alpha Testnet (using Truffle) <a id="moonbase-vrf"></a>

* Follow the instructions in the [VRF example README](./dapps/evm2/randomness/README.md)

### Build & Upload Chainlink VRFD20 Randomness Solidity Smart Contract to Ethereum Sepolia Testnet (using Truffle) <a id="vrfd20"></a>

* Follow the instructions in the [VRF20 example README](./dapps/evm2/randomness/README.md)

### Build & Upload ink! Rust Flipper Smart Contract to Local Testnet (using Cargo Contract) <a id="build-upload"></a>

* Create Rust project with template
Expand Down Expand Up @@ -249,12 +316,12 @@ Note: Try `rustup update` if you face error

Local Testnet
```bash
swanky contract deploy flipper --account alice -g 100000000000 -a true
swanky contract deploy flipper --account alice -g 1000000000000 -a true
```

Shibuya Testnet
```bash
swanky contract deploy flipper --account alice --gas 100000000000 --args true --network shibuya
swanky contract deploy flipper --account alice --gas 1000000000000 --args true --network shibuya
```
Copy paste the contract address.

Expand Down Expand Up @@ -359,8 +426,8 @@ cargo contract call \
* 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
```bash
--skip-dry-run \
--gas 100000000000 \
--proof-size 100000000000
--gas 1000000000000 \
--proof-size 1000000000000
```

### Tips Docker Commands <a id="tips-docker"></a>
Expand Down Expand Up @@ -424,6 +491,9 @@ docker buildx rm --all-inactive
* Contracts pallet allows deployment and execution of WebAssembly-based smart contracts
* What trait do smart contract accounts used in the Contracts pallet of Substrate extend?
* `Currency` trait
* How to resolve `ERROR: This contract has already been uploaded with code hash`
* 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
both the host machine and inside the Docker container. Or just restart Docker.


* Link
Expand Down
9 changes: 9 additions & 0 deletions dapps/basic_contract_caller/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Ignore build artifacts from the local tests sub-crate.
/target/

# Ignore backup files creates by cargo fmt.
**/*.rs.bk

# Remove Cargo.lock when creating an executable, leave it for libraries
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
Cargo.lock
37 changes: 37 additions & 0 deletions dapps/basic_contract_caller/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "basic_contract_caller"
version = "4.2.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
publish = false

[dependencies]
ink = { version = "4.2", default-features = false }

scale = { package = "parity-scale-codec", version = "3.5.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.7", default-features = false, features = ["derive"], optional = true }

# Note: We **need** to specify the `ink-as-dependency` feature.
#
# If we don't we will end up with linking errors!
other_contract = { path = "other_contract", default-features = false, features = ["ink-as-dependency"] }

[dev-dependencies]
ink_e2e = { version = "4.2.0" }

[lib]
path = "lib.rs"

[features]
default = ["std"]
std = [
"ink/std",
"scale/std",
"scale-info/std",

# Note: The metadata generation step requires `std`. If we don't specify this the metadata
# generation for our contract will fail!
"other_contract/std",
]
ink-as-dependency = []
e2e-tests = []
Loading