diff --git a/docs/zkapps/getting-started-zkapps.mdx b/docs/zkapps/getting-started-zkapps.mdx index d290f2218..92c19a951 100644 --- a/docs/zkapps/getting-started-zkapps.mdx +++ b/docs/zkapps/getting-started-zkapps.mdx @@ -7,7 +7,7 @@ keywords: - zkapps - mina protocol - smart contracts - - zero-knowledge proofs + - zero knowledge proofs - off-chain execution - typescript - quickstart zkapps @@ -21,7 +21,7 @@ zkApp programmability is not yet available on the Mina Mainnet. You can get star # zkApps Getting Started -You can start writing zkApps with just a few steps. You can write zkApps for your project in other ways, this Getting Started Guide provides a high-level workflow to build and deploy quickly. +You can start writing zkApps with just a few steps. The focus of this Getting Started Guide is a high-level workflow to build and deploy quickly. ## High-Level Workflow @@ -30,7 +30,9 @@ You can start writing zkApps with just a few steps. You can write zkApps for you 1. [Add testing code](#3-add-testing-code) 1. [Add functionality](#4-add-functionality) 1. [Create an integration test](#5-create-an-integration-test) -1. [Test with a live network](#6-test-with-a-live-network) +1. [Test locally](#6-test-with-local-simulated-blockchain) +1. [Test with Lightnet](#7-test-with-lightnet) +1. [Test with a live network](#8-test-with-a-live-network) ### 1. Install or update the zkApp CLI @@ -66,14 +68,14 @@ When you use the zkApp CLI to create a project, tests and examples are included. 1. See the `import` statements in the [Add.test.ts](https://github.com/o1-labs/zkapp-cli/blob/main/templates/project-ts/src/Add.test.ts#L1-L2) example file. -1. A `LocalBlockchain` instance to interact with is included in the [Add.test.ts](https://github.com/o1-labs/zkapp-cli/blob/main/templates/project-ts/src/Add.test.ts#L27-L28) example file. +1. A simulated `LocalBlockchain` instance you can interact with is included in the [Add.test.ts](https://github.com/o1-labs/zkapp-cli/blob/main/templates/project-ts/src/Add.test.ts#L27-L28) example file. -1. In o1js, an array of 10 test accounts to pay fees and sign transactions are provided for the `LocalBlockchain` instance. These can be accessed with `Local.testAccounts` as shown in the [Add.test.ts](https://github.com/o1-labs/zkapp-cli/blob/main/templates/project-ts/src/Add.test.ts#L29-L31) example file. The example uses the public/private key pairs of two of these accounts. The example uses these names, but the names can be anything: +1. In o1js, an array of 10 test accounts to pay fees and sign transactions are provided for the simulated `LocalBlockchain` instance. These can be accessed with `Local.testAccounts` as shown in the [Add.test.ts](https://github.com/o1-labs/zkapp-cli/blob/main/templates/project-ts/src/Add.test.ts#L29-L31) example file. The example uses the public/private key pairs of two of these accounts. The example uses these names, but the names can be anything: - `deployerAccount` deploys the smart contract - `senderAccount` pays transaction fees -1. Deploy the smart contract to the `LocalBlockchain` instance that simulates a network for testing purposes. +1. Deploy the smart contract to the simulated `LocalBlockchain` instance that simulates a network for testing purposes. See the `localDeploy` function in the [Add.test.ts](https://github.com/o1-labs/zkapp-cli/blob/main/templates/project-ts/src/Add.test.ts#L38-L46) example file. @@ -98,13 +100,52 @@ Add the logic for your smart contract. - If it works as expected with no errors, add more functionality. - If there are errors, look through the stack traces to find the source of the errors and update the contract to resolve them. -### 5. Create an integration test. +### 5. Create integration test - Create a Node.js script to run the smart contract and test it's functionality, similar to step [3. Add testing code](#3-add-testing-code). For an example, see the Node.js script that runs the Tic Tac Toe smart contract in the [run.ts](https://github.com/o1-labs/zkapp-cli/blob/main/examples/tictactoe/ts/src/run.ts) file. -### 6. Test with a live network +### 6. Test locally + +- [Test zkApps locally](/zkapps/testing-zkapps-locally) with a simulated local blockchain. + +### 7. Test with Lightnet + +- Use [Lightnet](/zkapps/testing-zkapps-lightnet) to test your zkApp with an accurate representation of Mina blockchain. + +1. Start Lightnet: + + ```sh + zk lightnet start + ``` + + The default settings start a single node that successfully serves the majority of testing requirements. + +1. Verify the status of the local blockchain: + + ```sh + zk lightnet status + ``` + +1. Communicate with the Mina Accounts-Manager service to fetch account details. + + - Mina Accounts-Manager is deployed to http://localhost:8181/ + - Use HTTP endpoints to acquire, release, list, lock, and unlock accounts + +1. Configure your zkApp for Lightnet blockchain. Use the endpoints provided by the `zk lightnet status` command. + + - Deploy name + - Set the Mina GraphQL API URL to deploy to: http://localhost:8080/graphql + - Set transaction fee to use when deploying (in MINA): 0.1 + +1. Deploy your zkApp to Lightnet: + + ```sh + zk deploy + ``` + +### 8. Test with a live network To deploy the smart contract to the Testnet, run the `zk` commands from the directory that contains your smart contract. @@ -116,7 +157,7 @@ To deploy the smart contract to the Testnet, run the `zk` commands from the dire Follow the prompts to specify a deploy alias name (can be anything), URL to deploy to, fee (in MINA) to be used when sending your deploy transaction, and the fee payer account. - For the Berkeley Testnet, use: + For the Berkeley Testnet, use: - Deploy alias name: `berkeley` @@ -184,7 +225,7 @@ To deploy the smart contract to the Testnet, run the `zk` commands from the dire node build/src/interact.js ``` -1. Keep building and experimenting! After you add features to your contract, repeat [7. Test with a live network](#6-test-with-a-live-network) to test with a live network. +1. Keep building and experimenting! After you add features to your contract, repeat [7. Test with a live network](#7-test-with-a-live-network) to test with a live network. ## Learn more @@ -194,4 +235,4 @@ Try the [zkApp Developer Tutorials](/zkapps/tutorials) for use cases that guide ## Get help and join the community -Join the [#zkapps-developers](https://discord.com/channels/484437221055922177/915745847692636181) channel on Mina Protocol Discord. +Join the [#zkapps-developers](https://discord.com/channels/484437221055922177/915745847692636181) channel on Mina Protocol Discord. \ No newline at end of file diff --git a/docs/zkapps/how-to-write-a-zkapp.mdx b/docs/zkapps/how-to-write-a-zkapp.mdx index 6a2a891c4..6924eb23b 100644 --- a/docs/zkapps/how-to-write-a-zkapp.mdx +++ b/docs/zkapps/how-to-write-a-zkapp.mdx @@ -233,4 +233,4 @@ For comprehensive details about the o1js API, see the [o1js reference](o1js-refe ## Next Steps -Now that you've learned how to write and operate a basic smart contract, you can learn [how to test your zkApp](how-to-test-a-zkapp). +Now that you've learned how to write and operate a basic smart contract, you can learn about [Testing zkApps Locally](/zkapps/testing-zkapps-locally). diff --git a/docs/zkapps/install-zkapp-cli.mdx b/docs/zkapps/install-zkapp-cli.mdx index 40e750e75..fa26c73d3 100644 --- a/docs/zkapps/install-zkapp-cli.mdx +++ b/docs/zkapps/install-zkapp-cli.mdx @@ -26,9 +26,9 @@ To build zero knowledge apps that use [o1js](/zkapps/o1js), you only need to ins ### Dependencies -- NodeJS v16 and later -- NPM v8 and later -- Git 2+ +- NodeJS v18 and later +- NPM v10 and later +- git v2 and later If you have a later version of a dependency, install the required version using the package manager for your system: diff --git a/docs/zkapps/o1js/actions-and-reducer.mdx b/docs/zkapps/o1js/actions-and-reducer.mdx index 47f5356c7..05b5873c8 100644 --- a/docs/zkapps/o1js/actions-and-reducer.mdx +++ b/docs/zkapps/o1js/actions-and-reducer.mdx @@ -114,7 +114,7 @@ In the near future, we want to add a function to retrieve actions from an archiv this.reducer.getActions({ fromActionState?: Field, endActionState?: Field }): A[][]; ``` -Right now, `getActions` is available for [testing with `LocalBlockchain`](/zkapps/how-to-test-a-zkapp). +Use `getActions` for testing with a simulated `LocalBlockchain`. See [Testing zkApps Locally](/zkapps/testing-zkapps-locally). ### Actions for concurrent state updates diff --git a/docs/zkapps/o1js/interact-with-mina.md b/docs/zkapps/o1js/interact-with-mina.md index 383611b1e..c538b701f 100644 --- a/docs/zkapps/o1js/interact-with-mina.md +++ b/docs/zkapps/o1js/interact-with-mina.md @@ -465,15 +465,15 @@ await pendingTx.wait(); // our account updates are applied on chain! ``` -In addition to `Mina.Metwork`, you can also use a mocked "Mina instance" for local testing: +In addition to `Mina.Network`, you can also use a simulated local blockchain for local testing: ```ts const Local = Mina.LocalBlockchain(); Mina.setActiveInstance(Local); ``` -Doing this means setting up a fresh, local ledger that is pre-filled with a couple of accounts with funds that you have access to. "Sending" a transaction here just means applying your account updates to that local Mina instance. This is helpful for testing, especially because account updates go through the same validation logic locally that they would on-chain. +Doing this means setting up a fresh, local ledger that is pre-filled with a couple of accounts with funds that you have access to. "Sending" a transaction here just means applying your account updates to that local simulated Mina instance. This is helpful for testing, especially because account updates go through the same validation logic locally that they would on-chain. -Fun fact: The `LocalBlockchain` instance literally uses the same OCaml code for transaction validation and application that the Mina node uses; it's compiled to JS with [js_of_ocaml](https://github.com/ocsigen/js_of_ocaml). +Fun fact: The `LocalBlockchain` instance literally uses the same OCaml code for transaction validation and application that the Mina node uses; it's compiled to JavaScript with [js_of_ocaml](https://github.com/ocsigen/js_of_ocaml). -You can learn more about testing in [How to test your zkApp](/zkapps/how-to-test-a-zkapp). +You can learn more about testing in [Test zkApps Locally](/zkapps/testing-zkapps-locally). diff --git a/docs/zkapps/testing-zkapps-lightnet.mdx b/docs/zkapps/testing-zkapps-lightnet.mdx new file mode 100644 index 000000000..b48217d68 --- /dev/null +++ b/docs/zkapps/testing-zkapps-lightnet.mdx @@ -0,0 +1,282 @@ +--- +title: Testing zkApps with Lightnet +hide_title: true +description: Use lightweight Mina blockchain network (Lightnet) for testing on a local blockchain before you test with a live network. +keywords: + - zkApp CLI + - lightnet + - zkApp testing + - Docker image + - using zk lightnet +--- + +# Testing zkApps with Lightnet + +The most efficient way to deploy and run a lightweight Mina blockchain network for testing purposes is to spin up a lightweight Mina network (Lightnet) in a single Docker container. Lightnet is a resource-efficient solution with fast startup and syncing times. + +Lightnet lets you test your zkApp locally on an accurate representation of Mina blockchain before you test with a live network. + +Lightnet provides the following benefits: + +- Reduces the time from ideation to launch by letting you test your applications and changes against a close-to-real Mina network. +- Starts a single-node network or a multi-node network with diverse types of participants. +- Creates and funds accounts so that you can deploy and interact with your zkApp. The genesis ledger is configured with 1000 pre-funded accounts with a 1550 MINA balance on each account. +- Optionally runs a Mina [archive node](/node-operators/archive-node). +- Provides the Mina accounts manager helper tool so you can automate account retrieval. +- Launches the lightweight Mina Explorer in a web browser so you can monitor transactions. +- Simplifies zkApp troubleshooting by providing convenient access to detailed logs. + +:::info + +Use of Lightnet is appropriate for local development and testing only. It is not intended to replicate all aspects of the full network. + +::: + +## Prerequisites + + +1. [Write tests for your smart contract](/zkapps/testing-zkapps-locally#writing-tests-for-your-smart-contract). + +1. [Test zkApps Locally](/zkapps/testing-zkapps-locally) on a simulated local blockchain. + +1. [Install Docker Engine]( +https://docs.docker.com/engine/install/). + + Docker Engine is required for your environment. + +1. Start Docker Engine. + + Docker Engine must be running before you can start the Lightnet Docker container. + +## High-Level Workflow for Lightnet + +1. [Write tests for your smart contract](/zkapps/testing-zkapps-locally#writing-tests-for-your-smart-contract) and test locally on a simulated local blockchain +1. Start Docker Engine +1. [Start Lightnet](#start-a-local-network) +1. Manage the [log files](#log-files) of the local network +1. Use [Lightweight Mina Explorer](#lightweight-mina-explorer) to visualize the local network state +1. Develop, iterate, and [troubleshoot](#troubleshoot-transactions) +1. [Stop the local network](#stop-the-local-network) + +## Start a local network + +Most of your zkApp testing can be done on a single node network. + +### Start a single node network + +To start a single node network with default behavior: + +```sh +zk lightnet start +``` + +This command performs the following operations that successfully serve the majority of testing requirements: + +- Pulls the latest Docker image for your environment from the [Docker Hub](https://hub.docker.com/r/o1labs/mina-local-network) repository +- Prepares the file system +- Downloads and updates the lightweight Mina Explorer +- Forms the network with a single node +- Configures the network to be fast +- Disables the blockchain SNARK proofs +- Uses the `o1js-main` branch of the Mina repository +- Starts the Mina archive process and the archive node API +- Waits for the network to reach a synchronized state +- Sets the Mina process logging level to trace + +### Start a local network with other settings + +To see the options to start a local blockchain network with non-default settings: + +```sh +zk lightnet start --help +``` + +You can configure different network properties. For example, to start a multi-node local blockchain network with slower, close-to-real-world properties: + +```sh +zk lightnet start --mode multi-node --type real +``` + +### Keep current versions + +New Docker images are built and published to the Docker Hub every night. You might not always want to get the latest product versions. For example, when your zkApp relies on well-defined APIs and you want to continue developing in your current environment. + +To keep your current working versions of o1js and Mina: + +```sh +zk lightnet start --no-pull +``` + +### Restart for a clean slate + +To reinstantiate Lightnet so you can redeploy and retest: + +```sh +zk lightnet stop +zk lightnet start +``` + +## Stop the local network + +To stop the local network, remove the Docker container, and clean up the environment: + +```sh +zk lightnet stop +``` + +When Lightnet is stopped, the log files for Docker container services are saved to the host file system at `/Users//.cache/zkapp-cli/lightnet/logs/`. + +To disable saving of log files: + +```sh +zk lightnet stop --no-save-logs +``` + +## Troubleshoot transactions + +Tools are provided for troubleshooting. + +### Lightweight Mina Explorer + +To monitor transactions, launch the lightweight Mina Explorer: + +```sh +zk lightnet explorer +``` + +By default, the latest version is launched. + +To list versions, their published dates, and show the version in use: + +```sh +zk lightnet explorer list true +``` + +To use a specific version of the lightweight Mina Explorer: + +```sh +zk lightnet explorer use +``` + +### Log files + +Log files for various processes are saved inside the Docker container as: + +- `/root/logs/*.log` +- `/root/.mina-network/mina-local-network-2-1-1/nodes/**/logs/*.log` + +To save the log files that are produced by Docker container processes to the host machine file system: + +```sh +zk lightnet logs save +``` + +To debug your zkApp, you can monitor the Docker container process logs in real time. + +On a different terminal window, to stream the process logs: + +```sh +zk lightnet logs follow +``` + +Select the Docker container process to follow. Press Ctrl+C to stop streaming. + + +### Lightnet status + +To get the network status: + +```sh +zk lightnet status +``` + +The network status is returned, including HTTP endpoints. For example, the default single node network status returns these endpoints: + +```text +- Mina Daemon GraphQL endpoint │ http://localhost:8080/graphql +- Accounts Manager endpoint │ http://localhost:8181 +- Archive-Node-API endpoint │ http://localhost:8282 +- PostgreSQL connection string │ postgresql://postgres:postgres@localhost:5432/archive +``` + +Use these URLs when you configure your zkApp. + +Lightnet status includes blockchain network properties, the Docker container state, and a code snippet of a zkApp using o1js API. + +Blockchain network properties include: + +- Sync status +- Commit ID +- Chain ID +- Consensus mechanism +- Consensus configuration + - Transaction finality ("k" blocks) + - Slot duration (new block every ~) + - Slots per Epoch +- SNARK work fee +- Known accounts +- Uptime + +## Accounts + +Each Docker image is packaged with a genesis ledger that is configured with more than 1000 prefunded accounts. Each account has a balance of 1550 MINA. + +The Mina Accounts-Manager helper tool provides a random public/private key pair that operates with accounts already configured in the genesis ledger. On Lightnet, the Mina Accounts-Manager is deployed to http://localhost:8181/. This endpoint is the same for all users and is available when Lightnet is up and running. + +Use HTTP endpoints to acquire, release, list, lock, and unlock accounts: + +```text +.:: Mina Accounts-Manager ::. +----------------------------- + +Application initialized and is running at: http://localhost:8181 +Available endpoints: + + HTTP GET: + http://localhost:8181/acquire-account + Supported Query params: + isRegularAccount=, default: true + Useful if you need to get non-zkApp account. + + unlockAccount=, default: false + Useful if you need to get unlocked account. + Returns JSON account key-pair: + { pk:"", sk:"" } + + HTTP PUT: + http://localhost:8181/release-account + Accepts JSON account key-pair as request payload: + { pk:"", sk:"" } + Returns JSON status message + + HTTP GET: + http://localhost:8181/list-acquired-accounts + Returns JSON list of acquired accounts key-pairs: + [ { pk:"", sk:"" }, ... ] + + HTTP PUT: + http://localhost:8181/lock-account + Accepts JSON account key-pair as request payload: + { pk:"", sk:"" } + Returns JSON status message + + HTTP PUT: + http://localhost:8181/unlock-account + Accepts JSON account key-pair as request payload: + { pk:"", sk:"" } + Returns JSON status message + +Operating with: + Mina Genesis ledger: /root/.mina-network/mina-local-network-2-1-1/daemon.json + Mina GraphQL endpoint: http://localhost:8080/graphql +``` + +**Advanced** The genesis ledger configuration file is `daemon.json`. You can manually access the Docker container file system to view and download the file. + +### zkApp Account Interactions + +The `acquireKeyPair()`, `releaseKeyPair()`, and `listAcquiredKeyPairs()` methods in the `Lightnet` o1js API namespace handle zkApp access to account information, including public keys, private keys, and secret keys. + +For details, see the [doc comments](https://github.com/o1-labs/o1js/blob/f5db874a3fd52635d3d77628696bc8e97f78b76c/src/lib/fetch.ts#L1012) in the code. + +For a real-world example of using Lightnet accounts, see [run_live.ts](https://github.com/o1-labs/o1js/blob/main/src/examples/zkapps/hello_world/run_live.ts) example file used in [Tutorial 1: Hello World](/zkapps/tutorials/hello-world). \ No newline at end of file diff --git a/docs/zkapps/how-to-test-a-zkapp.mdx b/docs/zkapps/testing-zkapps-locally.mdx similarity index 79% rename from docs/zkapps/how-to-test-a-zkapp.mdx rename to docs/zkapps/testing-zkapps-locally.mdx index 77a8802c7..de7a0b216 100644 --- a/docs/zkapps/how-to-test-a-zkapp.mdx +++ b/docs/zkapps/testing-zkapps-locally.mdx @@ -1,5 +1,5 @@ --- -title: How to Test a zkApp +title: Testing zkApps Locally hide_title: true description: Guided steps to write and run tests for your zkApp using the Jest JavaScript testing framework, create and run tests, create a local blockchain, deploy a contract locally, and write integration tests. keywords: @@ -17,26 +17,15 @@ zkApp programmability is not yet available on the Mina Mainnet. You can get star ::: -# How to Test a zkApp +# Testing zkApps Locally -Writing automated tests for your smart contract is essential to ensure your code is well-tested during development. - -## Test zkApps on a lightweight Mina local network - -A Docker image for Mina local networks provides a simple and efficient way to deploy and run lightweight Mina blockchain networks for testing zkApps. The `o1labs/mina-local-network` Docker image provides: - -- Genesis ledger with pre-funded accounts -- Accounts manager service -- Additional port served by reverse proxy to pass requests to the Mina daemon GraphQL endpoint so zkApps work without additional configuration -- Single commands to launch a single node or multi node network - -Pull the [o1labs/mina-local-network](https://hub.docker.com/r/o1labs/mina-local-network) image from Docker Hub. +Before you can test your zkApps, create automated tests for your smart contract and test with a simulated local blockchain. Test automation is essential to ensure your code is well-tested during development. ## Writing tests for your smart contract -All projects created using the Mina zkApp CLI include the [Jest](https://jestjs.io/) JavaScript testing framework. Although you can use any testing framework, the instructions in this document are supported for Jest. +All zkApp projects that are created using the zkApp CLI include the [Jest](https://jestjs.io/) JavaScript testing framework. Although you can use any testing framework, the instructions in this document are supported for Jest. -Use the Mina zkApp CLI to create tests for your smart contract. +Use the zkApp CLI to create tests for your smart contract. To scaffold a TypeScript file with a corresponding test file, run: @@ -46,7 +35,7 @@ The `foo.ts` and `foo.test.ts` files are generated. The `foo.test.ts` file is a great place to start writing your smart contract test code. To write valid unit tests, be sure you understand your smart contract functionality. -It's good practice to break down the functionality of your smart contract into `describe` blocks to organize your test groupings in the same file. By mapping out your unit tests using the `describe` convention, you provide documentation to developers who read your smart contract. +It's good practice to break down the functionality of your smart contract into `describe` blocks to organize your test groupings in the same file. By mapping out your unit tests using the `describe` convention, you provide helpful documentation to developers who read your smart contract. The following example shows the describe block for `test` in the `foo.test.ts` file: @@ -75,9 +64,9 @@ To generate a test coverage report for your project, run: The code coverage result is output to your terminal and shows the percentage of tested code. -### Creating a local blockchain +### Creating a simulated local blockchain -You can quickly test your smart contract by running it locally on a mock blockchain. +You can quickly test your smart contract by running it on a simulated local blockchain. The `Mina.LocalBlockchain()` method specifies a mock Mina ledger of accounts and contains logic for updating the ledger that can be used to test your smart contract. @@ -98,9 +87,9 @@ You can also programmatically enable and disable the `proofsEnabled` flag in you ### Deploying a contract locally -The mock Mina local blockchain contains test accounts you can use to deploy smart contracts and pay transaction fees. +The simulated local blockchain contains test accounts you can use to deploy smart contracts and pay transaction fees. -First, access a test account provided by the local blockchain. +First, access a test account provided by the simulated local blockchain. ```ts // Local.testAccounts is an array of 10 test accounts that have been pre-filled with Mina @@ -195,4 +184,4 @@ See the [Jest Getting Started](https://jestjs.io/docs/getting-started) documenta ## Next Steps -Now that you know how to test a smart contract, you can learn [how to deploy a zkApp](how-to-deploy-a-zkapp). +Now that you know how to test a smart contract on a simulated local blockchain, you can move on to [Testing zkApps with Lightnet](/zkapps/testing-zkapps-lightnet) before you learn [how to deploy a zkApp](how-to-deploy-a-zkapp). diff --git a/docs/zkapps/tutorials/01-hello-world.mdx b/docs/zkapps/tutorials/01-hello-world.mdx index b93f7d0d5..3bc80146d 100644 --- a/docs/zkapps/tutorials/01-hello-world.mdx +++ b/docs/zkapps/tutorials/01-hello-world.mdx @@ -36,7 +36,7 @@ You will: - 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. +- Use a simulated local Mina blockchain to interact with your smart contract. Later tutorials introduce more concepts and patterns. @@ -316,11 +316,16 @@ These import items are: - `PrivateKey`: A class with functions for manipulating private keys. - `AccountUpdate`: A class that generates a data structure that can update zkApp accounts. -### Local Blockchain +### Simulated Local Blockchain -Using a local blockchain speeds up development and tests the behavior of your smart contract locally. Later tutorials cover how to deploy a zkApp to live Mina networks. +Using a simulated local blockchain speeds up development and tests the behavior of your smart contract locally. Later tutorials cover how to use a lightweight Mina network (Lightnet) to test your zkApp before you deploy to live networks. -To initialize your local blockchain, add the following code from the [main.ts](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/01-hello-world/src/main.ts) example file to `src/main.ts`: +:::info +- The term _simulated local blockchain_ refers to the local testing blockchain you use in the first phase of testing as described here. +- The term _Lightnet_ is used to describe the lightweight Mina network (Lightnet) that is a more accurate representation of the Mina blockchain. See [Testing zkApps with Lightnet](/zkapps/testing-zkapps-lightnet). +::: + +To initialize your simulated local blockchain, add the following code from the [main.ts](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/01-hello-world/src/main.ts) example file to `src/main.ts`: ```ts src/main.ts 9 const useProof = false; @@ -331,7 +336,7 @@ To initialize your local blockchain, add the following code from the [main.ts](h 14 const { privateKey: senderKey, publicKey: senderAccount } = Local.testAccounts[1]; ``` -This local blockchain also provides pre-funded accounts. These lines create local test accounts with test MINA to use for this tutorial: +This simulated 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]; @@ -342,7 +347,7 @@ Tip: To preserve line numbers in your local `main.ts` file, add blank lines as n ### Build and run the smart contract -Now that the Square smart contract is complete, these commands run your project as a local blockchain. +Now that the Square smart contract is complete, these commands run your project as a simulated local blockchain. To compile the TypeScript code into JavaScript: diff --git a/docs/zkapps/tutorials/index.mdx b/docs/zkapps/tutorials/index.mdx index 2001df90f..5eaed4e2d 100644 --- a/docs/zkapps/tutorials/index.mdx +++ b/docs/zkapps/tutorials/index.mdx @@ -54,9 +54,9 @@ $ zk --version To use the zkApp CLI and o1js, your environment requires: -- NodeJS v16 and later (or NodeJS v14 using `--experimental-wasm-threads`) -- NPM v6 and later -- Git v2 and later +- NodeJS v18 and later +- NPM v10 and later +- git v2 and later Use a package manager to install the required versions and upgrade older versions if needed. Package managers for the supported environments are: diff --git a/docusaurus.config.js b/docusaurus.config.js index 8157d866b..43e759adc 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -78,11 +78,11 @@ module.exports = { }, { from: '/tutorials', - to: '/zkapps/tutorials/hello-world', + to: '/zkapps/tutorials/', }, { - from: '/zkapps/tutorials', - to: '/zkapps/tutorials/hello-world', + from: '/zkapps/how-to-test-a-zkapp', + to: '/zkapps/testing-zkapps-locally', }, { from: '/zkapps/simple-anonymous-message-board-tutorial', diff --git a/sidebars.js b/sidebars.js index 02b7beb43..a77974855 100644 --- a/sidebars.js +++ b/sidebars.js @@ -33,15 +33,16 @@ module.exports = { label: 'zkApp Developers', items: [ 'zkapps/index', + 'zkapps/how-zkapps-work', 'zkapps/getting-started-zkapps', 'zkapps/install-zkapp-cli', - 'zkapps/how-zkapps-work', { type: 'category', label: 'Creating zkApps', items: [ 'zkapps/how-to-write-a-zkapp', - 'zkapps/how-to-test-a-zkapp', + 'zkapps/testing-zkapps-locally', + 'zkapps/testing-zkapps-lightnet', 'zkapps/how-to-deploy-a-zkapp', 'zkapps/how-to-write-a-zkapp-ui', ],