Skip to content

Commit

Permalink
Merge pull request #507 from tanapl/docs/en
Browse files Browse the repository at this point in the history
Completed: added translation for docs
  • Loading branch information
yu23ki14 authored Feb 7, 2024
2 parents 4c3425d + b99c44e commit 90ec582
Show file tree
Hide file tree
Showing 8 changed files with 250 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ Solves the problem of organizers struggling with event retention rates.
## Development

- [Frontend](docs/frontend.md)
- [Contract](docs/contract.md)
- [Contract](docs/contract_en.md)
- [Run Localnode](docs/localnode.md)

## Deployment

- [Deploy](docs/deploy.md)
- [Deploy](docs/deploy_en.md)
1 change: 1 addition & 0 deletions circom
Submodule circom added at ccc8cd
35 changes: 35 additions & 0 deletions docs/contract_en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Setting Up Contract Development Environment (Until Test Code Execution)

## Installing Necessary Libraries

Install the following two libraries by following their respective instructions. Be aware that `snarkjs` should be installed globally.

1. [circom (a language for writing zero-knowledge proof circuits)](https://docs.circom.io/getting-started/installation/)
2. [snarkjs (a JavaScript library for computing zero-knowledge proofs)](https://www.npmjs.com/package/snarkjs)

Install NPM:

```shell
$ cd hardhat
$ pwd
~/hardhat
$ yarn
```

## Building the Zero-Knowledge Proof Circuit

```
$ yarn build:circuit
```

## Setting Up .env

```
$ cp .env.example .env
```

## Compilation and Test Execution

```
$ yarn test
```
File renamed without changes.
142 changes: 142 additions & 0 deletions docs/deploy_en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Deploy Contract on Testnet and Frontend on Vercel

## Deploy Contract

This document explains how to deploy to a testnet, but deploying to the mainnet can be done in almost the same way.

## 1. Create an OpenZeppelin Defender Account and Set Up Relayer and Autotask for Meta-Transactions

MintRally currently uses a service called Defender provided by OpenZeppelin for meta-transactions where the organizer bears the gas costs.

### 1.1 Create Defender Account

Access [Defender](https://www.openzeppelin.com/defender) and register as a new user.

### 1.2 Create Relayer

Create a Relayer by selecting the network you want to deploy to (Mumbai or Polygon). Gas costs will be paid from this Relayer.

![create relayer](documentImages/defender1.png)

To add MATIC as gas costs to the Relayer, please transfer funds to the Relayer's address from Metamask or similar. You can withdraw funds by clicking the 'Withdraw funds' button.

![relayer info](documentImages/defender2.png)

### 1.3 Create Relayer API Key

Open the menu by clicking on the gear icon located to the right of the Relayer name, and click the 'Create new API Key' button to issue an API key.

![generate api key](documentImages/defender-relayer-apikey.png)

Enter the issued key into the frontend environment variables under the names OZ_RELAYER_API_KEYS and OZ_RELAYER_API_SECRETS.

## 2. Set .env for Deployment

Set the following variables in your .env file. For deploying to Testnet, set variables starting with MUMBAI, and for Mainnet, set variables starting with POLYGON.

| Key | Value |
| --- | --- |
| MUMBAI_FORWARDER_ADDRESS | The Forwarder Address deployed to Mumbai testnet from Hardhat. For Mainnet deployment, set to `POLYGON_FORWARDER_ADDRESS`. |
| MUMBAI_RELAYER_ADDRESS | The Relayer Address obtained in 1.2. For Mainnet deployment, set to `POLYGON_RELAYER_ADDRESS`. |
| ETHERSCAN_API_KEY | Used for contract verification. Issue it from the scan service of the network you are deploying to. [Polygonscan](https://polygonscan.com/) |
| STAGING_ALCHEMY_KEY | Used to communicate with the blockchain during deployment. Issue from [Alchemy](https://www.alchemy.com/) by selecting the target network. For Mainnet deployment, set to `MAINNET_ALCHEMY_KEY`. |
| PRIVATE_KEY | Set the private key of the wallet that will be the contract creator. For Mainnet deployment, set to `MAINNET_PRIVATE_KEY`. |

## 3. Deploy to Testnet

### 3.1 Deploy to Testnet

```shell
// move to contract directory
$ cd hardhat

// deploy
$ yarn deploy:stg
```

Use `yarn deploy:main` when deploying to the mainnet.

After deploying to the testnet, the contract addresses will appear in the log.

```
forwarder address: 0x20a83f857c3632408486xxxxxxxxxx
mintNFT address: 0x51A0B20f98676f5EadB08870d0xxxxxxxxxx
eventManager address: 0xe26Df05190CD0f50c85C05Cb1B62xxxxxxxxxx
----------
For frontEnd
----------
NEXT_PUBLIC_FORWARDER_ADDRESS=0x20a83f857c3632408486b703036xxxxxxxxxx
NEXT_PUBLIC_CONTRACT_MINT_NFT_MANAGER=0x51A0B20f98676f5EadB08870xxxxxxxxxx
NEXT_PUBLIC_CONTRACT_EVENT_MANAGER=0xe26Df05190CD0f50c85C05Cb1B6268xxxxxxxxxx
```

### 3.2 Verify Deployed Contract

Verify the contract so that it can be seen on the scan site. Even without verification, MintRally is usable, but by doing this, users can more easily understand the contract and trust it.

Replace `<address>` with the contract address you got in 3.1 and run it three times for MintNFT, EventManager, and Forwarder.

```
$ yarn verify --network mumbai <address>
```

## Upload Defender Autotask Code

Upload the source code to OpenZeppelin's Autotask that intermediates meta-transactions.

```
// build autotask script
$ yarn build
// upload script
$ yarn upload:stg
```


Use `yarn upload:prd` when deploying to the mainnet.

# Deploy Frontend

## 4. Setup and Deploy on Vercel

NOTE: When deploying on Vercel, please be aware that using the `hobby` plan may result in a timeout and failure during proof generation. Therefore, it is recommended to use the `pro` plan (a paid plan).

### 4.1 Create a New Project

After creating an account on Vercel, go to the new project creation screen by selecting `Add New`, then `Project`.

![create new project](documentImages/vercel1.png)

Select the MintRally repository and click `Import`.
![import github](documentImages/vercel2.png)

### 4.2 Setup Vercel

Decide on any project name, choose `Next.js` for Framework Preset. Open the `Edit` screen from RootDirectory, select the frontend directory, and click `Continue`.

![import github](documentImages/vercel3.png)

![change root](documentImages/vercel4.png)

### 4.3 Set Environment Variables

Set the following environment variables in the Environment Variables section. Once you've set the variables, click the `Deploy` button to complete the setup.

![env](documentImages/vercel5.png)

| Key | Value |
| --- | --- |
| NEXT_PUBLIC_FORWARDER_ADDRESS | The forwarder contract address created in step 3.1 |
| NEXT_PUBLIC_CONTRACT_EVENT_MANAGER | The event manager contract address created in step 3.1 |
| NEXT_PUBLIC_CONTRACT_MINT_NFT_MANAGER | The mint NFT manager contract address created in step 3.1 |
| NEXT_PUBLIC_WEBHOOK_URL | The webhook URL obtained in 1.3 |
| NEXT_PUBLIC_PROVIDER_RPC | Issue from [Alchemy](https://www.alchemy.com/) by selecting the target network. It can be the same one used during contract deployment |
| NEXT_PUBLIC_CHAIN_ID | `80001` for Testnet, `137` for Mainnet |
| NEXT_PUBLIC_CHAIN_NAME | `Polygon Testnet` or `Polygon Mainnet` |
| NEXT_PUBLIC_BLOCK_EXPLORER_URL | `https://mumbai.polygonscan.com/` for Testnet, `https://polygonscan.com` for Mainnet |
| NEXT_PUBLIC_METAMASK_RPC_URL | The RPC URL for the wallet: `https://matic-mumbai.chainstacklabs.com` for Testnet, `https://polygon-rpc.com` for Mainnet |
| NEXT_PUBLIC_PINATA_JWT | Follow the instruction describing how to get a Pinata JWT. [link](/docs/frontend.md#create-pinata-jwt) |
| NEXT_PUBLIC_PINATA_GATEWAY | The general gateway URI is `gateway.pinata.cloud`. If you want to use your own gateway, please refer to the Pinata documentation |
| OZ_RELAYER_API_KEYS | Insert the Openzeppelin Relayer API Keys obtained in step 1.3 as an array |
| OZ_RELAYER_API_SECRETS | Insert the Openzeppelin Relayer API Secrets obtained in step 1.3 as an array |
4 changes: 3 additions & 1 deletion docs/deploy.md → docs/deploy_jp.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Relayer 名の右にある歯車アイコンからメニューを開き、Crete

| Key | Value |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| MUMBAI_FORWARDER_ADDRESS | Hardhat から mumbai テストネットにデプロイした ForwarderAddress。メインネットにデプロイする際は`POLYGON_FORWARDER_ADDRESS` にセットしてください。は。 |
| MUMBAI_FORWARDER_ADDRESS | Hardhat から mumbai テストネットにデプロイした ForwarderAddress。メインネットにデプロイする際は`POLYGON_FORWARDER_ADDRESS` にセットしてください。 |
| MUMBAI_RELAYER_ADDRESS | 1.2 で入手した RelayerAddress。メインネットにはデプロイする際は`POLYGON_RELAYER_ADDRESS` にセットしてください。 |
| ETHERSCAN_API_KEY | Contract を Verify するときに使います。デプロイ対象のネットワークの scan サービスから発行してください。[Polygonscan](https://polygonscan.com/) |
| STAGING_ALCHEMY_KEY | デプロイ時にブロックチェーンと通信するためにつかいます。[Alchemy](https://www.alchemy.com/)こちらから対象ネットワークを選択して発行してください。 `https://polygon-mumbai.g.alchemy.com/v2/vGk7cESxz`のような URL を入力します。メインネットにはデプロイする際は`MAINNET_ALCHEMY_KEY` にセットしてください。 |
Expand Down Expand Up @@ -85,6 +85,8 @@ $ yarn verify --network mumbai <address>

## 4. Setup and Deploy on Vercel

注意:Vercelにデプロイした際、`hobby`プランではproof生成時にタイムアウトとなり処理が失敗する可能性がありますので、`pro`プラン(課金プラン)の使用をお勧めします。

### 4.1 Create new project

Vercel でアカウント作成したら、`Add New``Project`で新規プロジェクト作成画面に入ってください。
Expand Down
66 changes: 66 additions & 0 deletions docs/devenv_mac_en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
## Install the development platforms that are prerequisites for developing MintRally
Install the following in order:
- Homebrew
- Node
- Yarn

## Install Homebrew
[Homebrew](https://brew.sh/index_ja "Link to the distribution site") is a package manager for macOS. Follow the instructions below to install Homebrew.

1. Open the Terminal. Use Spotlight search (Cmd + Space) and type 'Terminal' to launch it.

2. Execute the following command in the Terminal to install Homebrew.

```shell
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

3. Installation verification
```shell
brew --version
```
There's no specified version for Homebrew; if version information is displayed, then Homebrew is successfully installed, and you can proceed to the next step.
If no version information is displayed, there may be a typo in the install command or a network error, so please check the install log.

## Install Node
Node.js is a JavaScript runtime environment and platform for executing JavaScript on the server-side. Follow the instructions below to install Node.
1. Execute the following command in the Terminal to install Node.js.
```shell
brew install node@18
```
MintRally has been tested and confirmed to work with versions 16 and 18. Therefore, we specify version 18 for installation.

2. Since we've specified the Node version, it will be "keg-only" and not linked to the PATH, so execute the following command.

```shell
echo 'export PATH="/opt/homebrew/opt/node@18/bin:$PATH"' >> ~/.zshrc
```

3. Installation verification
```shell
node -v
```
If no version information is displayed, there may be a typo in the install command or a network error, so please check the install log.

## Install Yarn
Yarn is a package manager for JavaScript, a tool for managing dependencies and efficiently installing packages. Follow the instructions below to install Yarn.
1. Execute the following command in the Terminal to install Yarn.

```shell
npm install -g yarn
```

2. Installation verification
```shell
yarn --version
```
The version isn't important; as long as version information is displayed, the installation is successful, and you can proceed to the next step.
If no version information is displayed, there may be a typo in the install command or a network error, so please check the install log.

## Note
While Node and Yarn are mandatory for MintRally, Homebrew is not.
Thus, it is possible to install Node without Homebrew, but managing Node with Homebrew is the de facto standard for development on Mac. Therefore, we also install Homebrew as per this standard in this guide.

To comply with the constraints listed in [MintRally's dependencies](https://github.com/hackdays-io/mint-rally/blob/main/docs/frontend.md#dependencies), we are installing Version 16 of Node instead of the latest version.
Next.js is incorporated via yarn commands according to the contents of package.json so it is not mentioned in these instructions.
Any source code editor is fine to use, but VSC (VisualStudioCode) is recommended.
2 changes: 1 addition & 1 deletion docs/devenv_mac.md → docs/devenv_mac_jp.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## MintRally開発の前提となっている開発プラットホームをインストールする
## MintRally開発の前提となっている開発プラットホームをインストールする
- Homebrew
- node
- yarn
Expand Down

0 comments on commit 90ec582

Please sign in to comment.