File tree Expand file tree Collapse file tree
contract_samples/assemblyscript Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,24 +14,14 @@ export function get(): void {
1414export 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
2121export 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- }
Original file line number Diff line number Diff 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
3237export 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
Original file line number Diff line number Diff line change @@ -7,11 +7,11 @@ curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
77npm 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
1111Enable 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
1717Check bytecode is valid by validating it via RPC
Original file line number Diff line number Diff line change 44asc 0_counter.ts --target release --importMemory --memoryBase 65536 --outFile counter.wasm
55asc 1_deposit.ts --target release --importMemory --memoryBase 65536 --outFile deposit.wasm
66asc 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
89echo " "
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
1011echo " "
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
1215echo " "
Original file line number Diff line number Diff line change 33FROM ubuntu:24.04
44ENV 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
88ENV ELIXIR_VERSION=v1.19.4
99
1010RUN 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
1818RUN 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
2121RUN apt-get install -y pkg-config clang-19 lld-19 llvm-19-dev llvm-19-tools libclang-19-dev
2222
2323RUN ln -sf /usr/bin/llvm-config-19 /usr/local/bin/llvm-config
You can’t perform that action at this time.
0 commit comments