You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To get started, modify the component file at `./frontend/src/pages/index`.
6
+
7
+
!!! info
8
+
If you're new to Next.js but know React.js, getting used to Next.js is trivial.
9
+
To learn more about Next.js, [read their docs](https://nextjs.org/docs).
10
+
11
+
## Environment variables
12
+
13
+
Make sure you have followed the [steps in the quickstart](quickstart.md#set-up-environment-variables).
14
+
15
+
!!! note
16
+
All environment variable names exposed in client requests should be prefixed with `NEXT_PUBLIC_`.
17
+
18
+
## Connecting wallets
19
+
20
+
To connect a wallet, [Web3Modal v3](https://web3modal.com/) has been integrated and pre-configured for you.
21
+
22
+
Use the provided [`useWallet`](https://github.com/0xPolygon/dapp-launchpad/blob/scaffold-template/javascript/frontend/src/hooks/useWallet.js) hook to interact with Web3Modal and wallets. This contains utilities to simplify anything you need related to wallets.
23
+
24
+
## Sending transactions to smart contracts
25
+
26
+
To send transactions to either a locally deployed smart contract or a smart contract on a prod chain, use the [`useSmartContract`](https://github.com/0xPolygon/dapp-launchpad/blob/scaffold-template/javascript/frontend/src/hooks/useSmartContract.js) hook. This contains utilities that simplify getting and interacting with a Ethers.js contract instance.
27
+
28
+
When [deploying to local or production](https://0xpolygon.gitbook.io/dapp-launchpad/commands/deploy), this hook automatically uses the correct chain and contracts.
29
+
30
+
## Deploying to local test server
31
+
32
+
The [`dev`](https://0xpolygon.gitbook.io/dapp-launchpad/commands/dev) command automates everything needed for setting up a local Next.js test server.
33
+
34
+
## Deploying to Vercel
35
+
36
+
We use Vercel for deployments. Vercel offers free quotas to developers to get started.
37
+
38
+
To deploy, follow the [deployment steps](quickstart.md#deploy-your-app-to-production).
39
+
40
+
With the [`deploy`](https://0xpolygon.gitbook.io/dapp-launchpad/commands/deploy) command, the frontend deployment is fully automated.
41
+
42
+
No pre-configuration is necessary for running the `deploy` command. You'll be taken through all relevant steps upon running it.
You now have a fully integrated dev environment including a local dev blockchain and a local frontend dev server. Any changes to the code automatically updates both the frontend and the smart contracts. No manual reload is necessary.
91
+
92
+
### Start developing on an existing chain fork
93
+
94
+
You can start developing by forking an existing chain. To see the available options run the following:
95
+
96
+
```sh
97
+
dapp-launchpad dev -h
98
+
```
99
+
100
+
To fork Polygon zkEVM, for example, run the following command:
101
+
102
+
```sh
103
+
dapp-launchpad dev -n polygonZkevm
104
+
```
105
+
106
+
To fork at a particular block number run the command with the following optional flag:
107
+
108
+
```sh
109
+
dapp-launchpad dev -n polygonZkevm -b [BLOCK_NUMBER_TO_FORK_AT]
110
+
```
111
+
112
+
## Deploy your app to production
113
+
114
+
To deploy your project to production, run:
115
+
116
+
```sh
117
+
dapp-launchpad deploy -n <CHAIN-NAME>
118
+
```
119
+
120
+
This does two things:
121
+
122
+
1. Deploys all your smart contracts to the selected chain, and logs the deployment results.
123
+
2. Deploys your frontend to Vercel, and logs the deployment URL.
Make sure you have followed the [steps in the quickstart](quickstart.md#set-up-environment-variables).
4
+
5
+
## Framework
6
+
7
+
The smart contracts run on a [Hardhat](https://hardhat.org/) environment. They are written in [Solidity](https://docs.soliditylang.org/) and reside in the `smart-contracts` directory.
8
+
9
+
Tests are written in JS/TS, and are in the `tests` directory. An example test is available.
10
+
11
+
Scripts are also written in JS/TS, and reside in the `scripts` directory. Some mandatory scripts are already there to get started with.
12
+
13
+
## Deploying on local test chain
14
+
15
+
Follow the [start developing instructions](quickstart.md#start-developing) to spin up a local chain.
16
+
17
+
For all available options run:
18
+
19
+
```sh
20
+
dapp-launchpad dev -h
21
+
```
22
+
23
+
Internally, the `dev` command runs the `scripts/deploy_localhost` script that deploys all contracts in the correct sequence.
24
+
25
+
!!! warning
26
+
When working on your own smart contracts, make sure to update this script.
27
+
28
+
## Local test chain explorer
29
+
30
+
Optionally, you can enable a local blockchain explorer, which auto-indexes all transactions, and provides a feature-loaded dashboard with an overview of the chain.
31
+
32
+
To use it, run the `[dev]()` command with `-e`.
33
+
34
+
!!! info "Setting up an explorer"
35
+
- Sign up on [Ethernal](https://app.tryethernal.com/), and create a workspace.
36
+
- Then, add your login email, password, and workspace details in the `.env` file in the `smart-contracts` directly.
37
+
38
+
The above config can also be mentioned with [`dev`]() command params `--ethernal-login-email`, `--ethernal-login-password` and `--ethernal-workspace`, which override the preset environment variables.
39
+
40
+
Once started, you can access the chain explorer at the same URL as mentioned before.
41
+
42
+
## Deploying to production
43
+
44
+
The [`deploy`]() command automates deploying to any EVM compatible chain. It runs the provided `scripts/deploy_prod` script to deploy all contracts in the correct sequence. When working on your own smart contracts, make sure to update this script.
0 commit comments