From 1f481b4e41fda92b5c1bbd00bcec891c9c114a5e Mon Sep 17 00:00:00 2001 From: Bora Lee Date: Wed, 3 Jan 2024 06:26:24 +0900 Subject: [PATCH 1/2] Update docs/zkapps/tutorials/01-hello-world.mdx --- docs/zkapps/tutorials/01-hello-world.mdx | 11 +++++++---- examples/zkapps/01-hello-world/src/Square.ts | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/zkapps/tutorials/01-hello-world.mdx b/docs/zkapps/tutorials/01-hello-world.mdx index 7a12023d4..32ef3b0bb 100644 --- a/docs/zkapps/tutorials/01-hello-world.mdx +++ b/docs/zkapps/tutorials/01-hello-world.mdx @@ -162,6 +162,10 @@ In later tutorials, you learn how to interact with a smart contract from the bro The `src/index.ts` file contains all of the exports you want to make available for consumption from outside your smart contract project, such as from a UI. + :::info + The error message `File 'Square.ts' is not a module.` will disappear once the `Square` module is written, so it can be ignored for now. + ::: + ## Write the zkApp Smart Contract Now, the fun part! Write your smart contract in the `src/Square.ts` file. @@ -253,7 +257,7 @@ Finally, this code adds the `update()` function: 16 17 @method update(square: Field) { 18 const currentState = this.num.get(); -19 this.num.assertEquals(currentState); +19 this.num.requireEquals(currentState); 20 square.assertEquals(currentState.mul(currentState)); 21 this.num.set(square); 22 } @@ -485,10 +489,9 @@ The expected output is: ```sh $ npm run build && node build/src/main.js ... -o1js loaded state after init: 3 state after txn1: 9 -assert_equal: 75 != 81 +Field.assertEquals(): 75 != 81 state after txn2: 9 Shutting down ``` @@ -524,7 +527,7 @@ $ npm run build && node build/src/main.js o1js loaded state after init: 3 state after txn1: 9 -assert_equal: 75 != 81 +Field.assertEquals(): 75 != 81 state after txn2: 9 state after txn3: 81 Shutting down diff --git a/examples/zkapps/01-hello-world/src/Square.ts b/examples/zkapps/01-hello-world/src/Square.ts index dd2a91b67..cf00c2130 100644 --- a/examples/zkapps/01-hello-world/src/Square.ts +++ b/examples/zkapps/01-hello-world/src/Square.ts @@ -16,7 +16,7 @@ export class Square extends SmartContract { @method update(square: Field) { const currentState = this.num.get(); - this.num.assertEquals(currentState); + this.num.requireEquals(currentState); square.assertEquals(currentState.mul(currentState)); this.num.set(square); } From 4f59ae25ab29600ad40905009362fc08a9ee73e0 Mon Sep 17 00:00:00 2001 From: Barrie Byron Date: Wed, 14 Feb 2024 17:09:24 -0500 Subject: [PATCH 2/2] delete explain the error since I don't get it --- docs/zkapps/tutorials/01-hello-world.mdx | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/zkapps/tutorials/01-hello-world.mdx b/docs/zkapps/tutorials/01-hello-world.mdx index 32ef3b0bb..2471af004 100644 --- a/docs/zkapps/tutorials/01-hello-world.mdx +++ b/docs/zkapps/tutorials/01-hello-world.mdx @@ -162,9 +162,6 @@ In later tutorials, you learn how to interact with a smart contract from the bro The `src/index.ts` file contains all of the exports you want to make available for consumption from outside your smart contract project, such as from a UI. - :::info - The error message `File 'Square.ts' is not a module.` will disappear once the `Square` module is written, so it can be ignored for now. - ::: ## Write the zkApp Smart Contract