Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Trivo25 committed Aug 28, 2023
1 parent 968d26f commit 3ccbbc3
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 144 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-tutorials.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
288 changes: 144 additions & 144 deletions docs/zkapps/tutorials/03-deploying-to-a-network.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 <your-repo-url>
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 <your-repo-url>
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.

Expand All @@ -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.

Expand All @@ -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:

Expand All @@ -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/<username>/.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/<username>/.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/<txn-hash>`, where `<txn-hash>` 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/<txn-hash>`, where `<txn-hash>` 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
Expand All @@ -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.
Expand Down

0 comments on commit 3ccbbc3

Please sign in to comment.