From 38d75ad672c8422f25ce3ab3b9fa6645bce8fa54 Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 17 Aug 2023 19:04:37 +0200 Subject: [PATCH 01/17] test network runner --- .github/workflows/test-tutorials.yml | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/.github/workflows/test-tutorials.yml b/.github/workflows/test-tutorials.yml index fa2b6302f..7cdd1ea6f 100644 --- a/.github/workflows/test-tutorials.yml +++ b/.github/workflows/test-tutorials.yml @@ -17,3 +17,43 @@ jobs: git config --global user.email "test@example.com" git config --global user.name "Test" npx ts-node scripts/tutorial-runner.ts docs/zkapps/tutorials/01-hello-world.mdx + + deploying-network: + timeout-minutes: 25 + runs-on: ubuntu-latest + services: + mina-local-network: + image: o1labs/mina-local-network:rampup-latest-lightnet + env: + NETWORK_TYPE: 'single-node' + PROOF_LEVEL: 'none' + ports: + - 3085:3085 + - 5432:5432 + - 8080:8080 + - 8181:8181 + # TODO: Disable logging for container as the workaround of long post-job-cleanup phase + # - Will be fixed by improving logging as part of the work on: + # - https://hub.docker.com/r/o1labs/mina-local-network + options: --log-driver=none + steps: + - name: Wait for Mina Network readiness + uses: o1-labs/wait-for-mina-network-action@v1 + with: + mina-graphql-port: 8080 + max-attempts: 60 + polling-interval-ms: 10000 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 16 + - name: Run tutorial + env: + USE_LOCAL_NETWORK: 'true' + continue-on-error: false + run: | + npm ci + git config --global user.email "test@example.com" + git config --global user.name "Test" + npx ts-node scripts/tutorial-runner.ts docs/zkapps/tutorials/01-hello-world.md + shell: bash From 19a000a6b1e99ac20678ac4082ad863ca7aca3fb Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 17 Aug 2023 19:12:44 +0200 Subject: [PATCH 02/17] try fixing tutorial runner --- .github/workflows/test-tutorials.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-tutorials.yml b/.github/workflows/test-tutorials.yml index 7cdd1ea6f..dacf4ab8f 100644 --- a/.github/workflows/test-tutorials.yml +++ b/.github/workflows/test-tutorials.yml @@ -43,6 +43,8 @@ jobs: mina-graphql-port: 8080 max-attempts: 60 polling-interval-ms: 10000 + - name: Checkout Repository + uses: actions/checkout@v3 - name: Setup Node uses: actions/setup-node@v3 with: From 9752d7143af30bd7f622c6415abf2c6216503fe1 Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 17 Aug 2023 19:18:43 +0200 Subject: [PATCH 03/17] try fixing tutorial runner --- .github/workflows/test-tutorials.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test-tutorials.yml b/.github/workflows/test-tutorials.yml index dacf4ab8f..407014faa 100644 --- a/.github/workflows/test-tutorials.yml +++ b/.github/workflows/test-tutorials.yml @@ -58,4 +58,3 @@ jobs: git config --global user.email "test@example.com" git config --global user.name "Test" npx ts-node scripts/tutorial-runner.ts docs/zkapps/tutorials/01-hello-world.md - shell: bash From 0e9265376993161236d85cfd4b55cdc48f7188bb Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 17 Aug 2023 19:25:44 +0200 Subject: [PATCH 04/17] try fixing tutorial runner --- .github/workflows/test-tutorials.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-tutorials.yml b/.github/workflows/test-tutorials.yml index 407014faa..e5cde4687 100644 --- a/.github/workflows/test-tutorials.yml +++ b/.github/workflows/test-tutorials.yml @@ -43,10 +43,8 @@ jobs: mina-graphql-port: 8080 max-attempts: 60 polling-interval-ms: 10000 - - name: Checkout Repository - uses: actions/checkout@v3 - - name: Setup Node - uses: actions/setup-node@v3 + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: node-version: 16 - name: Run tutorial From f6de3b75741adebe06d0fb3a7a77a565c3a3d603 Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 17 Aug 2023 19:31:09 +0200 Subject: [PATCH 05/17] try fixing tutorial runner --- .github/workflows/test-tutorials.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-tutorials.yml b/.github/workflows/test-tutorials.yml index e5cde4687..7b6d76161 100644 --- a/.github/workflows/test-tutorials.yml +++ b/.github/workflows/test-tutorials.yml @@ -55,4 +55,5 @@ jobs: npm ci git config --global user.email "test@example.com" git config --global user.name "Test" + pwd npx ts-node scripts/tutorial-runner.ts docs/zkapps/tutorials/01-hello-world.md From 968d26f9a73a206692b1f8fd4c300c15cd86baf7 Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 17 Aug 2023 20:00:18 +0200 Subject: [PATCH 06/17] try fixing tutorial runner --- .github/workflows/test-tutorials.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test-tutorials.yml b/.github/workflows/test-tutorials.yml index 7b6d76161..012bda271 100644 --- a/.github/workflows/test-tutorials.yml +++ b/.github/workflows/test-tutorials.yml @@ -43,7 +43,6 @@ jobs: mina-graphql-port: 8080 max-attempts: 60 polling-interval-ms: 10000 - - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: 16 From 3ccbbc35a0b48229440f5b79201f62992f40f79a Mon Sep 17 00:00:00 2001 From: Florian Date: Mon, 28 Aug 2023 12:50:29 +0200 Subject: [PATCH 07/17] formatting --- .github/workflows/test-tutorials.yml | 1 + .../tutorials/03-deploying-to-a-network.mdx | 288 +++++++++--------- 2 files changed, 145 insertions(+), 144 deletions(-) diff --git a/.github/workflows/test-tutorials.yml b/.github/workflows/test-tutorials.yml index 012bda271..7b6d76161 100644 --- a/.github/workflows/test-tutorials.yml +++ b/.github/workflows/test-tutorials.yml @@ -43,6 +43,7 @@ jobs: mina-graphql-port: 8080 max-attempts: 60 polling-interval-ms: 10000 + - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: 16 diff --git a/docs/zkapps/tutorials/03-deploying-to-a-network.mdx b/docs/zkapps/tutorials/03-deploying-to-a-network.mdx index a2559d8a0..f0fad9682 100644 --- a/docs/zkapps/tutorials/03-deploying-to-a-network.mdx +++ b/docs/zkapps/tutorials/03-deploying-to-a-network.mdx @@ -26,11 +26,11 @@ zkApp programmability is not yet available on the Mina Mainnet. You can get star # Tutorial 3: Deploy to a Live Network -In previous tutorials, you learned how to deploy and run transactions on a local network. +In previous tutorials, you learned how to deploy and run transactions on a local network. In this tutorial, you use the `zk config` command to create a deploy alias, request tMINA funds to pay for transaction fees, and deploy a project to a live network. -Mina zkApps are available only on feature-complete Berkeley, Mina's public Testnet. This tutorial reuses the `Square` contract that you created in [Tutorial 1: Hello World](hello-world). +Mina zkApps are available only on feature-complete Berkeley, Mina's public Testnet. This tutorial reuses the `Square` contract that you created in [Tutorial 1: Hello World](hello-world). ## Prerequisites @@ -44,45 +44,46 @@ Ensure your environment meets the [Prerequisites](/zkapps/tutorials#prerequisite 2. Create a project by using the `zk project` command: - ```sh - $ zk project 03-deploying-to-a-live-network - ``` - - The `zk project` command has the ability to scaffold the UI for your project. For this tutorial, select `none`: - - ``` - ? Create an accompanying UI project too? … - next - svelte - nuxt - empty - ❯ none - ``` - The expected output is: - - ```sh - ✔ Create an accompanying UI project too? · none - ✔ UI: Set up project - ✔ Initialize Git repo - ✔ Set up project - ✔ NPM install - ✔ NPM build contract - ✔ Set project name - ✔ Git init commit - - Success! - - Next steps: - cd 03-deploying-to-a-live-network - git remote add origin - git push -u origin main - ``` - - The `zk project` command creates the `03-deploying-to-a-live-network` directory that contains the scaffolding for your project, including tools such as the Prettier code formatting tool, the ESLint static code analysis tool, and the Jest JavaScript testing framework. +```sh +$ zk project 03-deploying-to-a-live-network +``` + +The `zk project` command has the ability to scaffold the UI for your project. For this tutorial, select `none`: + +``` +? Create an accompanying UI project too? … + next + svelte + nuxt + empty +❯ none +``` + +The expected output is: + +```sh +✔ Create an accompanying UI project too? · none +✔ UI: Set up project +✔ Initialize Git repo +✔ Set up project +✔ NPM install +✔ NPM build contract +✔ Set project name +✔ Git init commit + +Success! + +Next steps: + cd 03-deploying-to-a-live-network + git remote add origin + git push -u origin main +``` + +The `zk project` command creates the `03-deploying-to-a-live-network` directory that contains the scaffolding for your project, including tools such as the Prettier code formatting tool, the ESLint static code analysis tool, and the Jest JavaScript testing framework. 1. Change into the `03-deploying-to-a-live-network` directory. -For this tutorial, you run commands from the root of the `03-deploying-to-a-live-network` directory as you work in the `src` directory on files that contain the TypeScript code for the smart contract. +For this tutorial, you run commands from the root of the `03-deploying-to-a-live-network` directory as you work in the `src` directory on files that contain the TypeScript code for the smart contract. Each time you make updates, then build or deploy, the TypeScript code is compiled into JavaScript in the `build` directory. @@ -92,17 +93,17 @@ Start by deleting the default files that come with the new project. 1. Delete the default generated files: - ```sh - $ rm src/Add.ts - $ rm src/Add.test.ts - $ rm src/interact.ts - ``` +```sh +$ rm src/Add.ts +$ rm src/Add.test.ts +$ rm src/interact.ts +``` 1. Now, create a new file for your smart contract: - ```sh - $ zk file src/Square - ``` +```sh +$ zk file src/Square +``` 1. Copy the `src/Square.ts` and `src/index.ts` files from the example files for first tutorial [01-hello-world/src](https://github.com/o1-labs/docs2/tree/main/examples/zkapps/01-hello-world/src) to your local `03-deploying-to-a-live-network/src` directory. If prompted, replace existing files. @@ -114,15 +115,15 @@ You already installed the Mina zkApp CLI as part of the [Prerequisites](/zkapps/ In some cases, you might need to create a custom account for your zkApp, for example, to deploy a zkApp to a different key than the fee payer key, programmatically parameterize a zkApp before you initialize it, or create a smart contract programmatically for users as part of an application. For details, see [Interacting with zkApps server-side](/zkapps/tutorials/interacting-with-zkapps-server-side). -## Deploy the smart contract +## Deploy the smart contract -The `config.json` configuration file was automatically scaffolded when you created your project with the `zk project` command. However, the generated configuration file does not yet contain the deploy alias. +The `config.json` configuration file was automatically scaffolded when you created your project with the `zk project` command. However, the generated configuration file does not yet contain the deploy alias. ### Deploy alias -The `zk config` command prompts guide you to create or update a deploy alias in your project `config.json` file. +The `zk config` command prompts guide you to create or update a deploy alias in your project `config.json` file. -You can have one or more deploy aliases for your project. +You can have one or more deploy aliases for your project. A deploy alias consists of: @@ -141,122 +142,121 @@ A deploy alias consists of: 1. To configure your deployment, run the `zk config` command and respond to the prompts: - ```sh - $ zk config - ``` +```sh +$ zk config +``` + +For this tutorial on Berkeley Testnet, use: + + - Deploy alias name: `berkeley` - For this tutorial on Berkeley Testnet, use: - - - Deploy alias name: `berkeley` - This tutorial uses `berkeley`, but the deploy alias name can be anything and does not have to match the network name. - + - Mina GraphQL API URL: `https://proxy.berkeley.minaexplorer.com/graphql` - + - Transaction fee to use when deploying: `0.1` - - - Account to pay transaction fees: Create a new fee payer pair + - Account to pay transaction fees: Create a new fee payer pair 1. When prompted to choose an account to pay transaction feeds, select to use a different account: - ```sh - Use a different account (select to see options) - ``` +```sh +Use a different account (select to see options) +``` -1. Next, select to create a new fee payer key pair: +1. Next, select to create a new fee payer key pair: - ```sh - Create a new fee payer key pair - NOTE: the private key will be stored in plain text on this computer. - ``` +```sh +Create a new fee payer key pair +NOTE: the private key will be stored in plain text on this computer. +``` 1. When prompted, give an alias to your new fee payer key pair. For this tutorial, use `03-deploy`: - ```sh - Create an alias for this account: 03-deploy - ``` +```sh +Create an alias for this account: 03-deploy +``` - Your key pairs and deploy alias are created: +Your key pairs and deploy alias are created: - ```sh - ✔ Create fee payer key pair at /Users//.cache/zkapp-cli/keys/03-deploy.json - ✔ Create zkApp key pair at keys/berkeley2.json - ✔ Add deploy alias to config.json +````sh +✔ Create fee payer key pair at /Users//.cache/zkapp-cli/keys/03-deploy.json +✔ Create zkApp key pair at keys/berkeley2.json +✔ Add deploy alias to config.json - Success! +Success! - Next steps: - - If this is a testnet, request tMINA at: - https://faucet.minaprotocol.com/?address=B62qqK5JgYAtmh2DHsQfUjUSKwQ6CFSPkGvyMZd19j1BUHfEJEqpKGo&?explorer=minaexplorer - - To deploy, run: `zk deploy berkeley` +Next steps: + - If this is a testnet, request tMINA at: + https://faucet.minaprotocol.com/?address=B62qqK5JgYAtmh2DHsQfUjUSKwQ6CFSPkGvyMZd19j1BUHfEJEqpKGo&?explorer=minaexplorer + - To deploy, run: `zk deploy berkeley` 1. Request funds from the Testnet Faucet to fund your fee payer account. - Follow the prompts to request tMINA. For this tutorial, your MINA address is populated on the Testnet Faucet. tMINA arrives at your address when the next block is produced (~3 minutes). +Follow the prompts to request tMINA. For this tutorial, your MINA address is populated on the Testnet Faucet. tMINA arrives at your address when the next block is produced (~3 minutes). 1. To deploy your project: - ```sh - $ zk deploy - ``` +```sh +$ zk deploy +```` 1. At the interactive prompt, select the `berkeley` deploy alias: - ```text - ? Which deploy alias would you like to deploy to? … - ❯ berkeley - ``` - - A verification key for your smart contract is generated (takes 10-30 seconds). - - The deploy process is output: - - ```text - ✔ Build project - ✔ Generate build.json - ✔ Choose smart contract - Only one smart contract exists in the project: Square - Your config.json was updated to always use this - smart contract when deploying to this deploy alias. - ✔ Generate verification key (takes 10-30 sec) - ⠋ Build transaction...(node:25066) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time - (Use `node --trace-warnings ...` to show where the warning was created) - ✔ Build transaction - ``` - -1. Review and confirm the details of the transaction: - - ```text - ✖ Confirm to send transaction - - ┌─────────────────┬─────────────────────────────────────────────────┐ - │ Deploy Alias │ berkeley2 │ - ├─────────────────┼─────────────────────────────────────────────────┤ - │ Fee-Payer Alias │ 03-deploy │ - ├─────────────────┼─────────────────────────────────────────────────┤ - │ URL │ https://proxy.berkeley.minaexplorer.com/graphql │ - ├─────────────────┼─────────────────────────────────────────────────┤ - │ Smart Contract │ Square │ - └─────────────────┴─────────────────────────────────────────────────┘ - ``` - - When prompted, type `yes` to confirm and send the transaction. - - ```text - ✔ Send to network - - Success! Deploy transaction sent. - - Next step: - Your smart contract will be live (or updated) - as soon as the transaction is included in a block: - ``` - -1. To see the zkApp transaction, go to `https://berkeley.minaexplorer.com/transaction/`, where `` is the transaction hash that is output to your terminal. - - - The zkApp Pending Transaction shows until the transaction is included in the next block. - - The zkApp Transaction shows after the transaction is included in a block. +```text +? Which deploy alias would you like to deploy to? … +❯ berkeley +``` + +A verification key for your smart contract is generated (takes 10-30 seconds). + +The deploy process is output: + +```text +✔ Build project +✔ Generate build.json +✔ Choose smart contract + Only one smart contract exists in the project: Square + Your config.json was updated to always use this + smart contract when deploying to this deploy alias. +✔ Generate verification key (takes 10-30 sec) +⠋ Build transaction...(node:25066) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time +(Use `node --trace-warnings ...` to show where the warning was created) +✔ Build transaction +``` + +1. Review and confirm the details of the transaction: + +```text +✖ Confirm to send transaction + + ┌─────────────────┬─────────────────────────────────────────────────┐ + │ Deploy Alias │ berkeley2 │ + ├─────────────────┼─────────────────────────────────────────────────┤ + │ Fee-Payer Alias │ 03-deploy │ + ├─────────────────┼─────────────────────────────────────────────────┤ + │ URL │ https://proxy.berkeley.minaexplorer.com/graphql │ + ├─────────────────┼─────────────────────────────────────────────────┤ + │ Smart Contract │ Square │ + └─────────────────┴─────────────────────────────────────────────────┘ +``` + +When prompted, type `yes` to confirm and send the transaction. + +```text +✔ Send to network + +Success! Deploy transaction sent. + +Next step: + Your smart contract will be live (or updated) + as soon as the transaction is included in a block: +``` + +1. To see the zkApp transaction, go to `https://berkeley.minaexplorer.com/transaction/`, where `` is the transaction hash that is output to your terminal. + + - The zkApp Pending Transaction shows until the transaction is included in the next block. + - The zkApp Transaction shows after the transaction is included in a block. ## Success @@ -281,13 +281,13 @@ Congratulations! ## About the Smart Contract Transactions -Because this tutorial used the smart contract for Tutorial 1: Hello World, the smart contract `editState` permissions require that a transaction must contain a valid zk proof that was created by the private key associated with this zkApp account. +Because this tutorial used the smart contract for Tutorial 1: Hello World, the smart contract `editState` permissions require that a transaction must contain a valid zk proof that was created by the private key associated with this zkApp account. -- When a user interacts with this smart contract by providing a proof, the proof is generated locally on the user's device and included in a transaction. -- When the transaction is submitted to the network, the proof is checked to ensure it is correct and matches the on-chain verification key. +- When a user interacts with this smart contract by providing a proof, the proof is generated locally on the user's device and included in a transaction. +- When the transaction is submitted to the network, the proof is checked to ensure it is correct and matches the on-chain verification key. - After the transaction is accepted, the proof and transaction are recursively proved and bundled into Mina's recursive zero knowledge proof. -When you change the smart contract code, the associated verification key also changes. Use the same steps to redeploy the smart contract. +When you change the smart contract code, the associated verification key also changes. Use the same steps to redeploy the smart contract. For a typical smart contract, permissions are set to allow only proof authorization: the proof in zero knowledge proof. You learn more about setting permissions in a later tutorial. From aec35bdc779eb635274a32249f4552972aaf692a Mon Sep 17 00:00:00 2001 From: Florian Date: Mon, 28 Aug 2023 12:57:35 +0200 Subject: [PATCH 08/17] cd into working dir --- .github/workflows/test-tutorials.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-tutorials.yml b/.github/workflows/test-tutorials.yml index 7b6d76161..b866e9b0a 100644 --- a/.github/workflows/test-tutorials.yml +++ b/.github/workflows/test-tutorials.yml @@ -55,5 +55,5 @@ jobs: npm ci git config --global user.email "test@example.com" git config --global user.name "Test" - pwd + cd .. npx ts-node scripts/tutorial-runner.ts docs/zkapps/tutorials/01-hello-world.md From 3e431a2a17436389fa89a5b37b7ba824d06b1e39 Mon Sep 17 00:00:00 2001 From: Florian Date: Mon, 28 Aug 2023 13:03:40 +0200 Subject: [PATCH 09/17] change checkout package version --- .github/workflows/test-tutorials.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-tutorials.yml b/.github/workflows/test-tutorials.yml index b866e9b0a..b160f8036 100644 --- a/.github/workflows/test-tutorials.yml +++ b/.github/workflows/test-tutorials.yml @@ -43,7 +43,7 @@ jobs: mina-graphql-port: 8080 max-attempts: 60 polling-interval-ms: 10000 - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - uses: actions/setup-node@v3 with: node-version: 16 @@ -55,5 +55,5 @@ jobs: npm ci git config --global user.email "test@example.com" git config --global user.name "Test" - cd .. + ls npx ts-node scripts/tutorial-runner.ts docs/zkapps/tutorials/01-hello-world.md From e4ce0a33081c244b6fe83e5f1e5895130b62d592 Mon Sep 17 00:00:00 2001 From: Florian Date: Mon, 28 Aug 2023 13:10:44 +0200 Subject: [PATCH 10/17] change tutorial path --- .github/workflows/test-tutorials.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test-tutorials.yml b/.github/workflows/test-tutorials.yml index b160f8036..e16b0552c 100644 --- a/.github/workflows/test-tutorials.yml +++ b/.github/workflows/test-tutorials.yml @@ -55,5 +55,4 @@ jobs: npm ci git config --global user.email "test@example.com" git config --global user.name "Test" - ls - npx ts-node scripts/tutorial-runner.ts docs/zkapps/tutorials/01-hello-world.md + npx ts-node scripts/tutorial-runner.ts docs/zkapps/tutorials/03-deploying-to-a-network.mdx From 80a5dc7e155205914dd446c05a16dc9b3f77e8d4 Mon Sep 17 00:00:00 2001 From: Florian Date: Mon, 28 Aug 2023 13:53:15 +0200 Subject: [PATCH 11/17] e2e test script, wip --- .github/workflows/test-tutorials.yml | 21 -- docs/zkapps/tutorials/01-hello-world.mdx | 220 +++++++++--------- .../tutorials/03-deploying-to-a-network.mdx | 76 +++++- 3 files changed, 177 insertions(+), 140 deletions(-) diff --git a/.github/workflows/test-tutorials.yml b/.github/workflows/test-tutorials.yml index e16b0552c..bef0c363c 100644 --- a/.github/workflows/test-tutorials.yml +++ b/.github/workflows/test-tutorials.yml @@ -21,28 +21,7 @@ jobs: deploying-network: timeout-minutes: 25 runs-on: ubuntu-latest - services: - mina-local-network: - image: o1labs/mina-local-network:rampup-latest-lightnet - env: - NETWORK_TYPE: 'single-node' - PROOF_LEVEL: 'none' - ports: - - 3085:3085 - - 5432:5432 - - 8080:8080 - - 8181:8181 - # TODO: Disable logging for container as the workaround of long post-job-cleanup phase - # - Will be fixed by improving logging as part of the work on: - # - https://hub.docker.com/r/o1labs/mina-local-network - options: --log-driver=none steps: - - name: Wait for Mina Network readiness - uses: o1-labs/wait-for-mina-network-action@v1 - with: - mina-graphql-port: 8080 - max-attempts: 60 - polling-interval-ms: 10000 - uses: actions/checkout@v2 - uses: actions/setup-node@v3 with: diff --git a/docs/zkapps/tutorials/01-hello-world.mdx b/docs/zkapps/tutorials/01-hello-world.mdx index b762f3f23..494b3c8eb 100644 --- a/docs/zkapps/tutorials/01-hello-world.mdx +++ b/docs/zkapps/tutorials/01-hello-world.mdx @@ -26,21 +26,21 @@ zkApp programmability is not yet available on the Mina Mainnet. You can get star # Tutorial 1: Hello World -This Hello World tutorial helps you get started with SnarkyJS, zkApps, and programming with zero-knowledge proofs. +This Hello World tutorial helps you get started with SnarkyJS, zkApps, and programming with zero-knowledge proofs. In this step-by-step tutorial, you learn to code a zkApp from start to finish. -You will: +You will: - Write a basic smart contract that stores a number as on-chain state. -- The contract logic allows this number to be replaced only by its square; for example, 3 -> 9 -> 81, and so on. +- The contract logic allows this number to be replaced only by its square; for example, 3 -> 9 -> 81, and so on. - Create a project using the [Mina zkApp CLI](https://www.npmjs.com/package/zkapp-cli) - Write your smart contract code - Use a local Mina blockchain to interact with your smart contract. -Later tutorials introduce more concepts and patterns. +Later tutorials introduce more concepts and patterns. -The full source code for this tutorial is provided in the [examples/zkapps/01-hello-world](https://github.com/o1-labs/docs2/tree/main/examples/zkapps/01-hello-world) directory on GitHub. While you're there, give the `/docs2` repository a star so that other zk developers can learn to build a zkApp! +The full source code for this tutorial is provided in the [examples/zkapps/01-hello-world](https://github.com/o1-labs/docs2/tree/main/examples/zkapps/01-hello-world) directory on GitHub. While you're there, give the `/docs2` repository a star so that other zk developers can learn to build a zkApp! :::info @@ -65,66 +65,67 @@ Now that you have the tooling installed, you can start building your application 1. Create or change to a directory where you have write privileges. 1. Now, create a project using the `zk project` command: - ```sh - $ zk project 01-hello-world - ``` - - The `zk project` command has the ability to scaffold the UI for your project. For this tutorial, select `none`: - - ``` - ? Create an accompanying UI project too? … - next - svelte - nuxt - empty - ❯ none - ``` - The expected output is: - - ```sh - ✔ Create an accompanying UI project too? · none - ✔ UI: Set up project - ✔ Initialize Git repo - ✔ Set up project - ✔ NPM install - ✔ NPM build contract - ✔ Set project name - ✔ Git init commit - - Success! - - Next steps: - cd 01-hello-world - git remote add origin - git push -u origin main - ``` - - The `zk project` command creates the `01-hello-world` directory that contains the scaffolding for your project, including tools such as the Prettier code formatting tool, the ESLint static code analysis tool, and the Jest JavaScript testing framework. +```sh +$ zk project 01-hello-world +``` + +The `zk project` command has the ability to scaffold the UI for your project. For this tutorial, select `none`: + +``` +? Create an accompanying UI project too? … + next + svelte + nuxt + empty +❯ none +``` + +The expected output is: + +```sh +✔ Create an accompanying UI project too? · none +✔ UI: Set up project +✔ Initialize Git repo +✔ Set up project +✔ NPM install +✔ NPM build contract +✔ Set project name +✔ Git init commit + +Success! + +Next steps: + cd 01-hello-world + git remote add origin + git push -u origin main +``` + +The `zk project` command creates the `01-hello-world` directory that contains the scaffolding for your project, including tools such as the Prettier code formatting tool, the ESLint static code analysis tool, and the Jest JavaScript testing framework. 1. Change into the `01-hello-world` directory and list the contents: - ```sh - $ cd 01-hello-world - $ ls - ``` - - The output shows these results: - - ```sh - LICENSE - README.md - babel.config.cjs - build - config.json - jest-resolver.cjs - jest.config.js - keys - node_modules - package-lock.json - package.json - src - tsconfig.json - ``` +```sh +$ cd 01-hello-world +$ ls +``` + +The output shows these results: + +```sh +LICENSE +README.md +babel.config.cjs +build +config.json +jest-resolver.cjs +jest.config.js +keys +node_modules +package-lock.json +package.json +src +tsconfig.json +``` For this tutorial, you run commands from the root of the `01-hello-world` directory as you work in the `src` directory on files that contain the TypeScript code for the smart contract. Each time you make updates, then build or deploy, the TypeScript code is compiled into JavaScript in the `build` directory. @@ -134,59 +135,59 @@ Start by deleting the default files that come with the new project. 1. To delete the old files: - ```sh - $ rm src/Add.ts - $ rm src/Add.test.ts - $ rm src/interact.ts - ``` +```sh +$ rm src/Add.ts +$ rm src/Add.test.ts +$ rm src/interact.ts +``` 1. Now, create the new files for your project: - ```sh - $ zk file src/Square - $ touch src/main.ts - ``` +```sh +$ zk file src/Square +$ touch src/main.ts +``` - - The `zk file` command created the `src/Square.ts` and `src/Square.test.ts` test files. - - However, this tutorial does not include writing tests, so you just use the `main.ts` file as a script to interact with the smart contract and observe how it works. +- The `zk file` command created the `src/Square.ts` and `src/Square.test.ts` test files. +- However, this tutorial does not include writing tests, so you just use the `main.ts` file as a script to interact with the smart contract and observe how it works. -In later tutorials, you learn how to interact with a smart contract from the browser, like a typical end user. +In later tutorials, you learn how to interact with a smart contract from the browser, like a typical end user. 3. Now, open `src/index.ts` in a text editor and change it to look like: - ```ts src/index.ts - 1 import { Square } from './Square.js'; - 2 - 3 export { Square }; - ``` +```ts src/index.ts +1 import { Square } from './Square.js'; +2 +3 export { Square }; +``` - 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. +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. ## Write the zkApp Smart Contract -Now, the fun part! Write your smart contract in the `src/Square.ts` file. +Now, the fun part! Write your smart contract in the `src/Square.ts` file. Line numbers are provided for convenience. A final version of the smart contract is provided in the [Square.ts](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/01-hello-world/src/Square.ts) example file. -This part of the tutorial walks you through the `Square` smart contract code already completed in the `src/Square.ts` example file. +This part of the tutorial walks you through the `Square` smart contract code already completed in the `src/Square.ts` example file. -### Copy the example +### Copy the example -This tutorial describes each part of the completed code in the [Square.ts](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/01-hello-world/src/Square.ts) example file. +This tutorial describes each part of the completed code in the [Square.ts](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/01-hello-world/src/Square.ts) example file. 1. First, open the [Square.ts](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/01-hello-world/src/Square.ts) example file. 1. Copy the entire contents of the file into your smart contract in the `src/Square.ts` file. -Now you are ready to review the imports in the smart contract. +Now you are ready to review the imports in the smart contract. ### Imports -The `import` statement brings in other packages and dependencies to use in your smart contract. +The `import` statement brings in other packages and dependencies to use in your smart contract. :::info -All functions used inside a smart contract must operate on SnarkyJS compatible data types: `Field` types and other types built on top of `Field` types. +All functions used inside a smart contract must operate on SnarkyJS compatible data types: `Field` types and other types built on top of `Field` types. :::info @@ -210,7 +211,7 @@ These items are: ### Smart contract class -Now, review the smart contract in the `src/Square.ts` file. +Now, review the smart contract in the `src/Square.ts` file. The smart contract called `Square` has one element of on-chain state named `num` of type `Field` as defined by following code: @@ -243,7 +244,7 @@ Since you're extending `SmartContract` that has its own initialization to perfor Then, `this.num.set(Field(3))` initializes the on-chain state `num` to a value of `3`. -You can optionally specify permissions. See [setPermissions](/zkapps/snarkyjs-reference/classes/SmartContract#setpermissions) in the SnarkyJS Reference documentation. +You can optionally specify permissions. See [setPermissions](/zkapps/snarkyjs-reference/classes/SmartContract#setpermissions) in the SnarkyJS Reference documentation. Finally, this code adds the `update()` function: @@ -262,40 +263,40 @@ Finally, this code adds the `update()` function: The function name `update` is arbitrary, but it makes sense for this example. Notice how the `@method` decorator is used because it is intended to be invoked by end users by using a zkApp UI, or as in this case, the `main.ts` script. -This method contains the logic by which end users are allowed to update the zkApp's account state on chain. +This method contains the logic by which end users are allowed to update the zkApp's account state on chain. -A zkApp account is an account is on the Mina blockchain where a zkApp smart contract is deployed. A zkApp account has a verification key associated with it. +A zkApp account is an account is on the Mina blockchain where a zkApp smart contract is deployed. A zkApp account has a verification key associated with it. In this example, the code specifies: -- If the user provides a number (for example, 9) to the `update()` method that is the square of the existing on-chain state referred to as `num` (for example, 3), then update the `num` value that is stored on-chain to the provided value (in this case, 9). +- If the user provides a number (for example, 9) to the `update()` method that is the square of the existing on-chain state referred to as `num` (for example, 3), then update the `num` value that is stored on-chain to the provided value (in this case, 9). - If the user provides a number that does not meet these conditions, they are unable to generate a proof or update the on-chain state. These update conditions are accomplished by using assertions within the method. When a user invokes a method on a smart contract, all assertions must be true to generate the zero-knowledge proof from that smart contract. The Mina network accepts the transaction and updates the on-chain state only if the attached proof is valid. This assertion is how you can achieve predictable behavior in an off-chain execution model. -Notice that `get()` and `set()` methods are used for retrieving and setting on-chain state. +Notice that `get()` and `set()` methods are used for retrieving and setting on-chain state. -- A smart contract retrieves the on-chain account state when it is first invoked if at least one `get()` exists within it. +- A smart contract retrieves the on-chain account state when it is first invoked if at least one `get()` exists within it. - Similarly, using `set()` changes the transaction to indicate that changes to this particular on-chain state are updated only when the transaction is received by the Mina network if it contains a valid authorization (usually, a valid authorization is a proof). -The logic also uses the `.mul()` method for multiplication of the values stored in `Field` types. You can view all available methods in the [SnarkyJS Reference](/zkapps/snarkyjs-reference) documentation. +The logic also uses the `.mul()` method for multiplication of the values stored in `Field` types. You can view all available methods in the [SnarkyJS Reference](/zkapps/snarkyjs-reference) documentation. You remember that functions in your smart contract must operate on SnarkyJS compatible data types: `Field` types and other types built on top of `Field` types. Because a smart contract is really a zero-knowledge circuit, functions from random NPM packages work inside a smart contract only if the functions the contract provides operate on SnarkyJS-compatible data types. Importantly, data passed as an input to a smart contract method in SnarkyJS is private and never seen by the network. -You can also store data publicly on-chain when needed, like `num` in this example. A later tutorial covers an example that leverages privacy. +You can also store data publicly on-chain when needed, like `num` in this example. A later tutorial covers an example that leverages privacy. -Congratulations, you have reviewed the complete smart contract code. +Congratulations, you have reviewed the complete smart contract code. ## Interact with a smart contract -Next, write a script that interacts with your smart contract. As before, the complete [main.ts](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/01-hello-world/src/main.ts) example file is provided. Follow these steps to build the `main.ts` file so you can can interact with the smart contract. +Next, write a script that interacts with your smart contract. As before, the complete [main.ts](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/01-hello-world/src/main.ts) example file is provided. Follow these steps to build the `main.ts` file so you can can interact with the smart contract. ### Imports -For this tutorial, the `import` statement brings in items from `snarkyjs` that you use to interact with your smart contract. +For this tutorial, the `import` statement brings in items from `snarkyjs` that you use to interact with your smart contract. 1. Copy the following lines from [main.ts](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/01-hello-world/src/main.ts) example file into the `src/main.ts` file: @@ -347,8 +348,10 @@ To initialize your local blockchain, add the following code from the [main.ts](h This local blockchain also provides pre-funded accounts. These lines create local test accounts with test MINA to use for this tutorial: ```ts ignore -const { privateKey: deployerKey, publicKey: deployerAccount } = Local.testAccounts[0]; -const { privateKey: senderKey, publicKey: senderAccount } = Local.testAccounts[1]; +const { privateKey: deployerKey, publicKey: deployerAccount } = + Local.testAccounts[0]; +const { privateKey: senderKey, publicKey: senderAccount } = + Local.testAccounts[1]; ``` Tip: To preserve line numbers in your local `main.ts` file, add blank lines as needed after you copy the code snippets. @@ -375,13 +378,13 @@ You have the option to combine these commands into one line: npm run build && node build/src/main.js ``` -- The `npm run build` command creates JavaScript code in the `build` directory. -- The `&&` operator links two commands together. The second command runs only if the first command is successful. +- The `npm run build` command creates JavaScript code in the `build` directory. +- The `&&` operator links two commands together. The second command runs only if the first command is successful. - The `node build/src/main.js` command runs the code in `src/main.ts`. ### Initialize your smart contract -To initialize your smart contract, add more code from the [main.ts](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/01-hello-world/src/main.ts) example file to the `src/main.ts` file. +To initialize your smart contract, add more code from the [main.ts](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/01-hello-world/src/main.ts) example file to the `src/main.ts` file. All smart contracts that you create with the zkApp CLI use similar code: @@ -475,9 +478,9 @@ Shutting down ### Add a transaction that fails -It's time to do some testing. To add a transaction that fails, add more code from the [main.ts](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/01-hello-world/src/main.ts) example file to the `src/main.ts` file. +It's time to do some testing. To add a transaction that fails, add more code from the [main.ts](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/01-hello-world/src/main.ts) example file to the `src/main.ts` file. -The contract logic allows the number that is stored as on-chain state to be replaced only by its square. Now that `num` is in state `9`, updating is possible only with `81`. +The contract logic allows the number that is stored as on-chain state to be replaced only by its square. Now that `num` is in state `9`, updating is possible only with `81`. To test a failure, update the state to 75 in `zkAppInstance.update(Field(75))`: @@ -569,10 +572,11 @@ Shutting down ## Follow along -You can follow along in this video as cryptographer, David Wong, learns how to code a Hello World project. +You can follow along in this video as cryptographer, David Wong, learns how to code a Hello World project. + -The video is provided for educational purposes and uses earlier versions of the zkApp CLI and SnarkyJS, so there are some differences. The Hello World tutorial always uses the most recent version of the zkApp CLI and SnarkyJS. +The video is provided for educational purposes and uses earlier versions of the zkApp CLI and SnarkyJS, so there are some differences. The Hello World tutorial always uses the most recent version of the zkApp CLI and SnarkyJS. ## Conclusion diff --git a/docs/zkapps/tutorials/03-deploying-to-a-network.mdx b/docs/zkapps/tutorials/03-deploying-to-a-network.mdx index f0fad9682..e95f173c3 100644 --- a/docs/zkapps/tutorials/03-deploying-to-a-network.mdx +++ b/docs/zkapps/tutorials/03-deploying-to-a-network.mdx @@ -44,6 +44,12 @@ Ensure your environment meets the [Prerequisites](/zkapps/tutorials#prerequisite 2. Create a project by using the `zk project` command: + + ```sh $ zk project 03-deploying-to-a-live-network ``` @@ -83,6 +89,12 @@ The `zk project` command creates the `03-deploying-to-a-live-network` directory 1. Change into the `03-deploying-to-a-live-network` directory. + + For this tutorial, you run commands from the root of the `03-deploying-to-a-live-network` directory as you work in the `src` directory on files that contain the TypeScript code for the smart contract. Each time you make updates, then build or deploy, the TypeScript code is compiled into JavaScript in the `build` directory. @@ -105,6 +117,42 @@ $ rm src/interact.ts $ zk file src/Square ``` + + 1. Copy the `src/Square.ts` and `src/index.ts` files from the example files for first tutorial [01-hello-world/src](https://github.com/o1-labs/docs2/tree/main/examples/zkapps/01-hello-world/src) to your local `03-deploying-to-a-live-network/src` directory. If prompted, replace existing files. Now that your smart contract is in place, you are ready to deploy your smart contract to Berkeley Testnet. @@ -142,8 +190,14 @@ A deploy alias consists of: 1. To configure your deployment, run the `zk config` command and respond to the prompts: +```sh ignore +zk config +``` + ```sh -$ zk config +$ echo '{ "privateKey": "EKE26wiE37cwvnsNHBB1NVQ27RstWdxEyzAbnhrYqnYGa1NoAcBT", "publicKey": "B62qpyCwp3qvU7sULu4RpWwzPUmKsSgFgPUjjFb3XXqYZX6ZUMtG7Ju" }' > keys/live-local-network.json +$ echo '{ "version": 1, "deployAliases": { "live-local-network": { "url": "https://api.minascan.io/node/berkeley/v1/graphql", "feepayerKeyPath": "keys/live-local-network.json", "feepayerAlias": "cli-fee-payer", "keyPath": "keys/live-local-network.json", "fee": "0.1" } } }' > config.json +$ zk deploy live-local-network ``` For this tutorial on Berkeley Testnet, use: @@ -160,26 +214,26 @@ For this tutorial on Berkeley Testnet, use: 1. When prompted to choose an account to pay transaction feeds, select to use a different account: -```sh +```sh ignore Use a different account (select to see options) ``` 1. Next, select to create a new fee payer key pair: -```sh +```sh ignore Create a new fee payer key pair NOTE: the private key will be stored in plain text on this computer. ``` 1. When prompted, give an alias to your new fee payer key pair. For this tutorial, use `03-deploy`: -```sh +```sh ignore Create an alias for this account: 03-deploy ``` Your key pairs and deploy alias are created: -````sh +````sh ignore ✔ Create fee payer key pair at /Users//.cache/zkapp-cli/keys/03-deploy.json ✔ Create zkApp key pair at keys/berkeley2.json ✔ Add deploy alias to config.json @@ -197,13 +251,13 @@ Follow the prompts to request tMINA. For this tutorial, your MINA address is pop 1. To deploy your project: -```sh -$ zk deploy +```sh ignore +zk deploy ```` 1. At the interactive prompt, select the `berkeley` deploy alias: -```text +```sh ignore ? Which deploy alias would you like to deploy to? … ❯ berkeley ``` @@ -212,7 +266,7 @@ A verification key for your smart contract is generated (takes 10-30 seconds). The deploy process is output: -```text +```sh ignore ✔ Build project ✔ Generate build.json ✔ Choose smart contract @@ -227,7 +281,7 @@ The deploy process is output: 1. Review and confirm the details of the transaction: -```text +```sh ignore ✖ Confirm to send transaction ┌─────────────────┬─────────────────────────────────────────────────┐ @@ -243,7 +297,7 @@ The deploy process is output: When prompted, type `yes` to confirm and send the transaction. -```text +```sh ignore ✔ Send to network Success! Deploy transaction sent. From 4fcfafb84f03f4f7496f67d43495b8e63a53a7d5 Mon Sep 17 00:00:00 2001 From: Florian Date: Mon, 28 Aug 2023 15:36:47 +0200 Subject: [PATCH 12/17] fix deploy script --- .github/workflows/test-tutorials.yml | 1 + docs/zkapps/tutorials/03-deploying-to-a-network.mdx | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-tutorials.yml b/.github/workflows/test-tutorials.yml index bef0c363c..9a43e15a3 100644 --- a/.github/workflows/test-tutorials.yml +++ b/.github/workflows/test-tutorials.yml @@ -32,6 +32,7 @@ jobs: continue-on-error: false run: | npm ci + npm run build --silent git config --global user.email "test@example.com" git config --global user.name "Test" npx ts-node scripts/tutorial-runner.ts docs/zkapps/tutorials/03-deploying-to-a-network.mdx diff --git a/docs/zkapps/tutorials/03-deploying-to-a-network.mdx b/docs/zkapps/tutorials/03-deploying-to-a-network.mdx index e95f173c3..5c167cd6e 100644 --- a/docs/zkapps/tutorials/03-deploying-to-a-network.mdx +++ b/docs/zkapps/tutorials/03-deploying-to-a-network.mdx @@ -145,7 +145,7 @@ $ zk file src/Square 23 } ``` -```ts src/Square.ts +```ts src/index.ts 1 import { Square } from './Square.js'; 2 3 export { Square }; @@ -197,7 +197,7 @@ zk config ```sh $ echo '{ "privateKey": "EKE26wiE37cwvnsNHBB1NVQ27RstWdxEyzAbnhrYqnYGa1NoAcBT", "publicKey": "B62qpyCwp3qvU7sULu4RpWwzPUmKsSgFgPUjjFb3XXqYZX6ZUMtG7Ju" }' > keys/live-local-network.json $ echo '{ "version": 1, "deployAliases": { "live-local-network": { "url": "https://api.minascan.io/node/berkeley/v1/graphql", "feepayerKeyPath": "keys/live-local-network.json", "feepayerAlias": "cli-fee-payer", "keyPath": "keys/live-local-network.json", "fee": "0.1" } } }' > config.json -$ zk deploy live-local-network +$ yes | zk deploy live-local-network ``` For this tutorial on Berkeley Testnet, use: From a193633e030ebb15f68428bf7e6e53129b61f9cd Mon Sep 17 00:00:00 2001 From: Florian Date: Mon, 28 Aug 2023 15:42:39 +0200 Subject: [PATCH 13/17] add local network container --- .github/workflows/test-tutorials.yml | 24 +++++++++++++++++-- .../tutorials/03-deploying-to-a-network.mdx | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-tutorials.yml b/.github/workflows/test-tutorials.yml index 9a43e15a3..a9d557b67 100644 --- a/.github/workflows/test-tutorials.yml +++ b/.github/workflows/test-tutorials.yml @@ -21,18 +21,38 @@ jobs: deploying-network: timeout-minutes: 25 runs-on: ubuntu-latest + services: + mina-local-network: + image: o1labs/mina-local-network:rampup-latest-lightnet + env: + NETWORK_TYPE: 'single-node' + PROOF_LEVEL: 'none' + ports: + - 3085:3085 + - 5432:5432 + - 8080:8080 + - 8181:8181 + # TODO: Disable logging for container as the workaround of long post-job-cleanup phase + # - Will be fixed by improving logging as part of the work on: + # - https://hub.docker.com/r/o1labs/mina-local-network + options: --log-driver=none steps: + - name: Wait for Mina Network readiness + uses: o1-labs/wait-for-mina-network-action@v1 + with: + mina-graphql-port: 8080 + max-attempts: 60 + polling-interval-ms: 10000 - uses: actions/checkout@v2 - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 20 - name: Run tutorial env: USE_LOCAL_NETWORK: 'true' continue-on-error: false run: | npm ci - npm run build --silent git config --global user.email "test@example.com" git config --global user.name "Test" npx ts-node scripts/tutorial-runner.ts docs/zkapps/tutorials/03-deploying-to-a-network.mdx diff --git a/docs/zkapps/tutorials/03-deploying-to-a-network.mdx b/docs/zkapps/tutorials/03-deploying-to-a-network.mdx index 5c167cd6e..258be521a 100644 --- a/docs/zkapps/tutorials/03-deploying-to-a-network.mdx +++ b/docs/zkapps/tutorials/03-deploying-to-a-network.mdx @@ -195,7 +195,7 @@ zk config ``` ```sh -$ echo '{ "privateKey": "EKE26wiE37cwvnsNHBB1NVQ27RstWdxEyzAbnhrYqnYGa1NoAcBT", "publicKey": "B62qpyCwp3qvU7sULu4RpWwzPUmKsSgFgPUjjFb3XXqYZX6ZUMtG7Ju" }' > keys/live-local-network.json +$ echo '{ "privateKey": "EKEnVLUhYHDJvgmgQu5SzaV8MWKNfhAXYSkLBRk5KEfudWZRbs4P", "publicKey": "B62qq1miZzh8QMumJ2dhJSvPxdeShGQ2G2cH4YXwxNLpPSvKdRVTb3q" }' > keys/live-local-network.json $ echo '{ "version": 1, "deployAliases": { "live-local-network": { "url": "https://api.minascan.io/node/berkeley/v1/graphql", "feepayerKeyPath": "keys/live-local-network.json", "feepayerAlias": "cli-fee-payer", "keyPath": "keys/live-local-network.json", "fee": "0.1" } } }' > config.json $ yes | zk deploy live-local-network ``` From d4fcb7e4118fed26368325082185c3bfbe3b73b7 Mon Sep 17 00:00:00 2001 From: Florian Date: Mon, 28 Aug 2023 15:53:07 +0200 Subject: [PATCH 14/17] hide auxiliary scripts --- docs/zkapps/tutorials/03-deploying-to-a-network.mdx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/zkapps/tutorials/03-deploying-to-a-network.mdx b/docs/zkapps/tutorials/03-deploying-to-a-network.mdx index 258be521a..1c0890302 100644 --- a/docs/zkapps/tutorials/03-deploying-to-a-network.mdx +++ b/docs/zkapps/tutorials/03-deploying-to-a-network.mdx @@ -194,11 +194,14 @@ A deploy alias consists of: zk config ``` + For this tutorial on Berkeley Testnet, use: From ae4fb832f95b3aa9495cbbea2ffbbd4eedd1abd3 Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 7 Sep 2023 13:06:38 +0200 Subject: [PATCH 15/17] fix grapqhl link --- docs/zkapps/tutorials/03-deploying-to-a-network.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zkapps/tutorials/03-deploying-to-a-network.mdx b/docs/zkapps/tutorials/03-deploying-to-a-network.mdx index 1c0890302..7550ceeec 100644 --- a/docs/zkapps/tutorials/03-deploying-to-a-network.mdx +++ b/docs/zkapps/tutorials/03-deploying-to-a-network.mdx @@ -198,7 +198,7 @@ zk config ```sh $ echo '{ "privateKey": "EKEnVLUhYHDJvgmgQu5SzaV8MWKNfhAXYSkLBRk5KEfudWZRbs4P", "publicKey": "B62qq1miZzh8QMumJ2dhJSvPxdeShGQ2G2cH4YXwxNLpPSvKdRVTb3q" }' > keys/live-local-network.json -$ echo '{ "version": 1, "deployAliases": { "live-local-network": { "url": "https://api.minascan.io/node/berkeley/v1/graphql", "feepayerKeyPath": "keys/live-local-network.json", "feepayerAlias": "cli-fee-payer", "keyPath": "keys/live-local-network.json", "fee": "0.1" } } }' > config.json +$ echo '{ "version": 1, "deployAliases": { "live-local-network": { "url": "http://localhost:8080/graphql", "feepayerKeyPath": "keys/live-local-network.json", "feepayerAlias": "cli-fee-payer", "keyPath": "keys/live-local-network.json", "fee": "0.1" } } }' > config.json $ yes | zk deploy live-local-network ``` ---> From e78945beb8c7cf1d00b0a8684f653eae5644bd6c Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 7 Sep 2023 13:47:39 +0200 Subject: [PATCH 16/17] update o1js reference --- docs/zkapps/tutorials/03-deploying-to-a-network.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/zkapps/tutorials/03-deploying-to-a-network.mdx b/docs/zkapps/tutorials/03-deploying-to-a-network.mdx index c704831f4..59a65e639 100644 --- a/docs/zkapps/tutorials/03-deploying-to-a-network.mdx +++ b/docs/zkapps/tutorials/03-deploying-to-a-network.mdx @@ -34,7 +34,7 @@ Mina zkApps are available only on feature-complete Berkeley, Mina's public Testn ## Prerequisites -This tutorial has been tested with [Mina zkApp CLI](https://github.com/o1-labs/zkapp-cli) version `0.10.0` and [SnarkyJS](https://www.npmjs.com/package/snarkyjs) `0.11.3`. +This tutorial has been tested with [Mina zkApp CLI](https://github.com/o1-labs/zkapp-cli) version `0.10.0` and [o1js](https://www.npmjs.com/package/o1js) `0.12.1`. Ensure your environment meets the [Prerequisites](/zkapps/tutorials#prerequisites) for zkApp Developer Tutorials. @@ -126,7 +126,7 @@ $ zk file src/Square 4 state, 5 State, 6 method -7 } from 'snarkyjs'; +7 } from 'o1js'; 8 9 export class Square extends SmartContract { 10 @state(Field) num = State(); @@ -198,7 +198,7 @@ zk config ```sh $ echo '{ "privateKey": "EKEnVLUhYHDJvgmgQu5SzaV8MWKNfhAXYSkLBRk5KEfudWZRbs4P", "publicKey": "B62qq1miZzh8QMumJ2dhJSvPxdeShGQ2G2cH4YXwxNLpPSvKdRVTb3q" }' > keys/live-local-network.json -$ echo '{ "version": 1, "deployAliases": { "live-local-network": { "url": "http://localhost:8080/graphql", "feepayerKeyPath": "keys/live-local-network.json", "feepayerAlias": "cli-fee-payer", "keyPath": "keys/live-local-network.json", "fee": "0.1" } } }' > config.json +$ echo '{ "version": 1, "deployAliases": { "live-local-network": { "url": "https://proxy.berkeley.minaexplorer.com/graphql", "feepayerKeyPath": "keys/live-local-network.json", "feepayerAlias": "cli-fee-payer", "keyPath": "keys/live-local-network.json", "fee": "0.1" } } }' > config.json $ yes | zk deploy live-local-network ``` ---> From 226be8e5fa6755f25e041ce8325fbfa68a1d4103 Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 7 Sep 2023 13:55:21 +0200 Subject: [PATCH 17/17] update graphql link --- docs/zkapps/tutorials/03-deploying-to-a-network.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zkapps/tutorials/03-deploying-to-a-network.mdx b/docs/zkapps/tutorials/03-deploying-to-a-network.mdx index 59a65e639..c21364f91 100644 --- a/docs/zkapps/tutorials/03-deploying-to-a-network.mdx +++ b/docs/zkapps/tutorials/03-deploying-to-a-network.mdx @@ -198,7 +198,7 @@ zk config ```sh $ echo '{ "privateKey": "EKEnVLUhYHDJvgmgQu5SzaV8MWKNfhAXYSkLBRk5KEfudWZRbs4P", "publicKey": "B62qq1miZzh8QMumJ2dhJSvPxdeShGQ2G2cH4YXwxNLpPSvKdRVTb3q" }' > keys/live-local-network.json -$ echo '{ "version": 1, "deployAliases": { "live-local-network": { "url": "https://proxy.berkeley.minaexplorer.com/graphql", "feepayerKeyPath": "keys/live-local-network.json", "feepayerAlias": "cli-fee-payer", "keyPath": "keys/live-local-network.json", "fee": "0.1" } } }' > config.json +$ echo '{ "version": 1, "deployAliases": { "live-local-network": { "url": "http://localhost:8080/graphql", "feepayerKeyPath": "keys/live-local-network.json", "feepayerAlias": "cli-fee-payer", "keyPath": "keys/live-local-network.json", "fee": "0.1" } } }' > config.json $ yes | zk deploy live-local-network ``` --->