Skip to main content
By the end of this tutorial, you will have a dApp project running locally with a local test blockchain, deployed smart contracts, and a Next.js frontend that updates automatically when you change code.

Prerequisites

  • Node.js version 18.x.x (recommended). Versions above 16.14.x are supported.
  • Use nvm to manage Node installations if you need multiple versions.

Step 1: Install the CLI

Open a terminal and install dApp Launchpad globally:
npm install -g @polygonlabs/dapp-launchpad

Step 2: Initialize a new project

dapp-launchpad init <PROJECT-NAME>
This creates a new directory, scaffolds a minimal dApp project, and installs the required packages.

Choose a template

By default, the project uses JavaScript. For TypeScript, pass the --template flag:
dapp-launchpad init <PROJECT-NAME> --template typescript
To see all available templates:
dapp-launchpad list scaffold-templates

Step 3: Set up environment variables

Both the frontend and smart-contracts directories require environment variables before you can start the dev environment.
  1. Change into your project directory:
    cd <PROJECT-NAME>
    
  2. Copy the frontend environment file:
    cd frontend
    cp .env.example .env
    
  3. Open the frontend .env file and add your NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID. To get a WalletConnect project ID:
    1. Create an account at WalletConnect Cloud and sign in.
    2. Select Create a new project.
    3. Give it a name and select Continue. You can leave the URL empty for now.
    4. Select AppKit and continue.
    5. Select Next.js and then select Create in the bottom right of the pop-up window.
    6. Copy the project ID from the sidebar and paste it into the frontend .env file.
  4. Copy the smart contracts environment file:
    cd ../smart-contracts
    cp .env.example .env
    
  5. Open the smart-contracts .env file and set the PRIVATE_KEY_DEPLOYER variable to a private key from any wallet account you control. The other variables in this file are optional.

Step 4: Start the development environment

Run the following from your project root:
dapp-launchpad dev
You will see the local test blockchain start, contracts deploy, and pre-funded wallets listed in the terminal output: Local test environment running Open http://localhost:3000 in a browser: Web application running You now have a fully integrated dev environment. Changes to smart contract code or frontend code update automatically. No manual reload is needed.

Developing against a forked chain

To fork an existing network instead of starting from genesis, pass the -n flag:
dapp-launchpad dev -n polygonZkevm
Available network names: ethereum, goerli, polygonPos, polygonAmoy, polygonZkevm, polygonZkevmTestnet To fork at a specific block number:
dapp-launchpad dev -n polygonZkevm -b [BLOCK_NUMBER_TO_FORK_AT]
To see all options:
dapp-launchpad dev -h

Deploy to production

To deploy both your smart contracts and frontend to production:
dapp-launchpad deploy -n <CHAIN-NAME>
This deploys all smart contracts to the selected chain, then deploys your frontend to Vercel, and logs the deployment URL for each. To deploy only smart contracts:
dapp-launchpad deploy -n CHAIN_NAME --only-smart-contracts
To deploy only the frontend:
dapp-launchpad deploy -n CHAIN_NAME --only-frontend
Frontend deployment requires that smart contracts are already deployed. If you are deploying only the frontend, either run the smart contracts deploy first, or manually generate the smart contracts config:
generate smart-contracts-config -e production -n CHAIN_NAME