diff --git a/.github/workflows/test-tutorials.yml b/.github/workflows/test-tutorials.yml index ebf7691c9..ebeed40d6 100644 --- a/.github/workflows/test-tutorials.yml +++ b/.github/workflows/test-tutorials.yml @@ -17,3 +17,42 @@ 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 + - uses: actions/checkout@v2 + - uses: actions/setup-node@v3 + with: + node-version: 20 + - 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/03-deploying-to-a-network.mdx diff --git a/docs/zkapps/tutorials/01-hello-world.mdx b/docs/zkapps/tutorials/01-hello-world.mdx index 59713b8f5..bf7bae2a2 100644 --- a/docs/zkapps/tutorials/01-hello-world.mdx +++ b/docs/zkapps/tutorials/01-hello-world.mdx @@ -30,17 +30,17 @@ This Hello World tutorial helps you get started with o1js, zkApps, and programmi 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,55 +135,55 @@ 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 @@ -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: @@ -262,20 +263,20 @@ 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). @@ -285,13 +286,13 @@ You remember that functions in your smart contract must operate on o1js compatib Importantly, data passed as an input to a smart contract method in o1js 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 @@ -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,7 +572,8 @@ 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 o1js, so there are some differences. The Hello World tutorial always uses the most recent version of the zkApp CLI and o1js. diff --git a/docs/zkapps/tutorials/03-deploying-to-a-network.mdx b/docs/zkapps/tutorials/03-deploying-to-a-network.mdx index ecd497f3f..c21364f91 100644 --- a/docs/zkapps/tutorials/03-deploying-to-a-network.mdx +++ b/docs/zkapps/tutorials/03-deploying-to-a-network.mdx @@ -26,15 +26,15 @@ 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 -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. @@ -44,45 +44,58 @@ 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 +105,53 @@ 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 +163,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 +190,130 @@ A deploy alias consists of: 1. To configure your deployment, run the `zk config` command and respond to the prompts: - ```sh - $ zk config - ``` +```sh ignore +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 ignore +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 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 - Create an alias for this account: 03-deploy - ``` +```sh ignore +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 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 - 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 ignore +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. +```sh ignore +? 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: + +```sh ignore +✔ 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: + +```sh ignore +✖ 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. + +```sh ignore +✔ 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 +338,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.