Skip to main content

Tutorial 3: Deploy to a Live Network

In previous tutorials, you learned how to deploy and execute transactions on a local network.

In this tutorial, you will use the zk config command to create the deploy alias, request tMINA funds to pay for transaction fees, and deploy zkApp to a live network.

This tutorial reuses the Square contract that you created in Tutorial 1: Hello World.


This tutorial has been tested with:

Ensure your environment meets the Prerequisites for zkApp Developer Tutorials.

If you have earlier versions of the zkApp CLI and o1js installed, be sure to Update the zkApp CLI to the latest version:

npm update -g zkapp-cli

Create a project

  1. Create or change to a directory where you have write privileges.

  2. Create a project by using the zk project command:

    $ 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? …
    > none

    The expected output is:

    ✔ 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


    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, the ESLint static code analysis, and the Jest JavaScript testing framework.

  3. 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.

Prepare the project

Start by deleting the default files that come with the new project.

  1. Delete the default generated files:

    $ rm src/Add.ts
    $ rm src/Add.test.ts
    $ rm src/interact.ts
  2. Copy the src/Square.ts and src/index.ts files from the files of the first tutorial 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 zkApp to Devnet.

zkApp CLI

You installed the zkApp CLI as part of the Prerequisites, so you already have the tools to manage deployments.

In some cases, you might need to create a custom account for your zkApp, programmatically parameterize a zkApp before you initialize it, or create a smart contract programmatically for users as part of an application. For details, please see Interacting with zkApps server-side.

Deploy the smart contract

The config.json configuration file contains the configuration to deploy your zkApp. This file was automatically created during the project scaffold 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 a deploy alias in your project config.json file.

You can have one or more deploy aliases for your project.

A deploy alias consists of:

  • A self-describing name that can be anything. Using naming patterns is helpful when you have more than one deploy alias.
  • The target network kind (Testnet, Mainnet or custom network kind id)
  • The Mina GraphQL API URL that defines the network that receives your deploy transaction and broadcasts it to the appropriate Mina network (Testnet, Devnet, Mainnet, and so on)
  • The transaction fee (in MINA) to use when deploying
  • Two key pairs:
    • A key pair for the zkApp account. Public and private keys to use in your application are automatically generated in keys/<deploy-alias-name>.json.
    • A key pair to use as a fee payer account for updates and deployments. Public and private keys are stored on your local computer and can be used across multiple projects.
  • Fee payer account alias
    • A fee payer account is required, you can choose to use an existing account or create a new fee payer account.
  1. To configure your deploy alias, run the zk config command and respond to the prompts:

    $ zk config

    For this tutorial on Devnet, use:

    • Deploy alias name: devnet

      This tutorial uses devnet, but the deploy alias name can be anything and does not have to match the network name.

    • Target network kind: Testnet

    • Mina GraphQL API URL:

    • Transaction fee to use when deploying (in MINA): 0.1

  2. When prompted to choose an account to pay transaction fees, select:

    Use a different account (select to see options)

    If this is the first time you are running the zk config command, you see these options:

    > Recover fee payer account from an existing base58 private key
    Create a new fee payer key pair

    A third option to choose another saved fee payer account is shown only if you have multiple cached fee payer accounts.

  3. Select to create a new fee payer key pair:

    Create a new fee payer key pair
    NOTE: the private key will be stored in plain text on this computer.

    Please mind the note above and do not use the fee payer account that holds a substantial amount of MINA.

  4. When prompted, give an alias to your new fee payer key pair. For this tutorial, use 03-deploy:

    ✔ Create an alias for this account · 03-deploy

    Your key pairs and deploy alias are created:

    ✔ Create fee payer key pair at ${HOME}/.cache/zkapp-cli/keys/03-deploy.json
    ✔ Create zkApp key pair at keys/devnet.json
    ✔ Add deploy alias to config.json


    Next steps:
    - If this is the testnet, request tMINA at:<FEE-PAYER-ACCOUNT>
    - To deploy zkApp, run: `zk deploy devnet`
  5. Request funds from the Testnet Faucet to fund your fee payer account.

    Follow the prompts to request tMINA. To get funds on the Devnet, use the URL that was shown in the zkApp CLI output:

    • Choose the corresponding network you're going to deploy your zkApp to (Devnet in this case)
    • And click the Request button

    Before proceeding to the next step, wait a few minutes for the next block to include your transaction, so that tMINA becomes available for the fee payer account.

  6. To deploy your project execute the following command:

    $ zk deploy
  7. At the interactive prompt, select the devnet deploy alias:

    ? Which deploy alias would you like to deploy to? …
    > devnet

    A verification key for your smart contract is generated (takes 10-30 seconds).

    The deploy process is output:

    ✔ 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
  8. Review and confirm the details of the transaction:

    ✔ Confirm to send transaction

    | Deploy alias | devnet |
    | Network kind | testnet |
    | URL | |
    | Fee payer | Alias : 03-deploy |
    | | Account : B62... |
    | zkApp | Smart contract: Square |
    | | Account : B62... |
    | Transaction fee | 0.1 Mina |

    When prompted, type yes to confirm and send the transaction to the network.

    ✔ Send to network

    Success! Deploy transaction sent.

    Next step:
    Your smart contract will be live (or updated)
    at B62...
    as soon as the transaction is included in a block:<txn-hash>?type=zk-tx
  9. To see the zkApp transaction and navigate to accounts involved you can follow the transaction link provided to you in zkApp CLI output. Or use the Minascan explorer to search for the account with deployed zkApp.


After the transaction is included in a block, your smart contract is deployed!

  • The Mina account used to deploy the zkApp now contains the verification key associated with this smart contract.

You ran the zk config command to:

  • Create a deploy alias
  • Create a fee payer key pair at ${HOME}/.cache/zkapp-cli/keys/03-deploy.json
  • Create a zkApp key pair at keys/devnet.json

You requested tMINA to fund your fee payer account and pay your deploy transaction fees. Use the remaining tMINA to keep building and testing.

You ran the zk deploy command to:

  • Generate a verification key for your smart contract
  • Add send the deploy transaction to the network


To test, configure, and deploy your zkApp on a local representation of the Mina blockchain, see Testing zkApps with Lightnet.

About the Smart Contract Transactions

Because this tutorial used the smart contract from Tutorial 1: Hello World, the smart contract's editState permissions require that the 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.
  • 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 your zkApp.

For a typical smart contract, permissions are set to only allow proof authorization. You learn more about setting permissions in the later tutorials.


Watch this tutorial for a step-by-step guide and extra explanations on how to deploy a zkApp.

The video is provided for educational purposes and uses earlier versions of the zkApp CLI and o1js, so there are some differences. This tutorial is tested with a specific version of the zkApp CLI and o1js.


Congratulations! You have successfully deployed a smart contract to a live network.

Check out Tutorial 4: Build a zkApp UI in the Browser with React to implement a browser UI that interacts with a smart contract.