Skip to content

Commit 27692eb

Browse files
committed
readme
1 parent 4c258f3 commit 27692eb

5 files changed

Lines changed: 18 additions & 20 deletions

File tree

contract_samples/assemblyscript/0_counter.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,14 @@ export function get(): void {
1414
export function increment(amount_ptr: i32): void {
1515
let amount = sdk.memory_read_string(amount_ptr)
1616
sdk.kv_increment("the_counter", amount)
17-
let incremented_counter = sdk.kv_increment("the_counter", roll_dice())
17+
let incremented_counter = sdk.kv_increment("the_counter", 1)
1818
sdk.ret(incremented_counter)
1919
}
2020

2121
export function increment_another_counter(contract_ptr: i32): void {
2222
let contract = sdk.memory_read_bytes(contract_ptr)
23-
let incr_by = roll_dice()
23+
let incr_by = 3
2424
sdk.log(`Calling increment on ${b58(contract)} by ${incr_by}`)
2525
let other_counter = sdk.call(contract, "increment", [b(incr_by)])
2626
sdk.ret(other_counter)
2727
}
28-
29-
//Current: VRF Stage 1 is used.
30-
//Seed is signature of previous VRF by current validator.
31-
//A malicious validator can do a withholding attack (not include a TX if the RNG is unfavorable)
32-
33-
//Coming Soon: VRF Stage 2 will be only attackable if 67% are malicious as it will use BLS Threshold /w DKG
34-
export function roll_dice(): i64 {
35-
const val = Math.random(); // Returns 0.0 to 1.0
36-
return floor(val * 6) as i32 + 1; // Returns 1-6
37-
}

contract_samples/assemblyscript/3_nft.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ export function claim(): void {
2929
sdk.ret(random_nft);
3030
}
3131

32+
//Current: VRF Stage 1 is used.
33+
//Seed is signature of previous VRF by current validator.
34+
//A malicious validator can do a withholding attack (not include a TX if the RNG is unfavorable)
35+
36+
//Coming Soon: VRF Stage 2 will be only attackable if 67% are malicious as it will use BLS Threshold /w DKG
3237
export function roll_dice(): i64 {
3338
const val = Math.random(); // Returns 0.0 to 1.0
3439
return floor(val * 6) as i32 + 1; // Returns 1-6

contract_samples/assemblyscript/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
77
npm install --global assemblyscript
88
```
99

10-
Build the deposit contract setting memory base to 65536 just in-case (not required)
10+
Build the deposit contract setting memory base to 65536
1111
Enable importMemory to allow calling imports
1212

1313
```bash
14-
asc 1_deposit.ts --target release --importMemory --memoryBase 65536 --outFile deposit.wasm
14+
asc 0_counter.ts --target release --importMemory --memoryBase 65536 --outFile counter.wasm
1515
```
1616

1717
Check bytecode is valid by validating it via RPC

contract_samples/assemblyscript/build_and_validate.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
asc 0_counter.ts --target release --importMemory --memoryBase 65536 --outFile counter.wasm
55
asc 1_deposit.ts --target release --importMemory --memoryBase 65536 --outFile deposit.wasm
66
asc 2_coin.ts --target release --importMemory --memoryBase 65536 --outFile coin.wasm
7-
curl -X POST -H "Content-Type: application/octet-stream" --data-binary @counter.wasm https://mainnet-rpc.ama.one/api/contract/validate_bytecode
7+
asc 3_nft.ts --target release --importMemory --memoryBase 65536 --outFile nft.wasm
8+
curl -X POST -H "Content-Type: application/octet-stream" --data-binary @counter.wasm https://mainnet-rpc.ama.one/api/contract/validate
89
echo ""
9-
curl -X POST -H "Content-Type: application/octet-stream" --data-binary @deposit.wasm https://mainnet-rpc.ama.one/api/contract/validate_bytecode
10+
curl -X POST -H "Content-Type: application/octet-stream" --data-binary @deposit.wasm https://mainnet-rpc.ama.one/api/contract/validate
1011
echo ""
11-
curl -X POST -H "Content-Type: application/octet-stream" --data-binary @coin.wasm https://mainnet-rpc.ama.one/api/contract/validate_bytecode
12+
curl -X POST -H "Content-Type: application/octet-stream" --data-binary @coin.wasm https://mainnet-rpc.ama.one/api/contract/validate
13+
echo ""
14+
curl -X POST -H "Content-Type: application/octet-stream" --data-binary @nft.wasm https://mainnet-rpc.ama.one/api/contract/validate
1215
echo ""

ex/build.Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
FROM ubuntu:24.04
44
ENV DEBIAN_FRONTEND noninteractive
55

6-
ENV SSL_VERSION=3.5.4
7-
ENV OTP_VERSION=OTP-28.2
6+
ENV SSL_VERSION=3.6.0
7+
ENV OTP_VERSION=OTP-28.3
88
ENV ELIXIR_VERSION=v1.19.4
99

1010
RUN apt-get update && apt-get install -y vim git curl locate wget apt-transport-https apt-utils locales
@@ -17,7 +17,7 @@ WORKDIR "/root"
1717

1818
RUN apt-get update && apt-get install -y build-essential autoconf libncurses-dev m4 xsltproc libxml2-utils unixodbc-dev
1919
#RUN apt-get update && apt-get install -y --no-install-recommends libwxgtk3.0-gtk3-dev
20-
RUN apt-get install -y libzstd1 zstd
20+
RUN apt-get install -y libzstd1 zstd mold
2121
RUN apt-get install -y pkg-config clang-19 lld-19 llvm-19-dev llvm-19-tools libclang-19-dev
2222

2323
RUN ln -sf /usr/bin/llvm-config-19 /usr/local/bin/llvm-config

0 commit comments

Comments
 (0)