-
Create a fork of this repository.
-
Clone your fork and navigate to the root directory.
-
Install project dependencies.
yarn install
-
Create a
.env
file in the root directory which mirrors the.example.env
file. Learn how to define each field in the.env
file in Setup.
juicebox-interface
relies on a number of services for development. Create an account for each of the following services:
The following sections describe how to set up each service for local development.
Juicebox uses Infura to connect to an Ethereum network (mainnet, or one of the testnets).
Take the following steps to create an Infura project for local development:
- Select Create New Key to begin creating a new Infura project.
- Select the Web 3 API option from the Network dropdown.
- Enter a Name (for example,
juicebox-local
). - Select Create to create the project.
Next, copy the following fields into your .env
file:
- Project ID. In the
.env
file, copy the Project ID into theNEXT_PUBLIC_INFURA_ID
variable. - Endpoint. This is the Ethereum network that will be used for testing. If you don't know which endpoint to use, select mainnet. In the
.env
file, copy the network name (e.g. 'mainnet', not the url) into theNEXT_PUBLIC_INFURA_NETWORK
variable.
- Select Create new key to begin creating a new Infura project.
- Select IPFS from the NETWORK dropdown.
- Enter a Name (for example,
juicebox-ipfs-local
). - Select Create to create the project.
Next, copy the following fields into your .env
file:
- PROJECT ID. In the
.env
file, copy the Project ID into theINFURA_IPFS_PROJECT_ID
variable. - API KEY SECRET. In the
.env
file, copy the API KEY SECRET into theINFURA_IPFS_API_SECRET
variable. - DEDICATED GATEWAY SUBDOMAIN. In the
.env
file, copy the DEDICATED GATEWAY SUBDOMAIN into theNEXT_PUBLIC_INFURA_IPFS_HOSTNAME
variable without thehttps://
prefix.
Juicebox uses Piñata to store project metadata. Juicebox projects set a name, description, logo, and other details when creating the project. These details are saved on IPFS as a JSON file using Piñata, and the CID gets stored on-chain with the Juicebox project.
Take the following steps to set up Piñata for local development:
- Create a Piñata API key (learn more).
- Enable the Admin toggle in the Admin field.
- Copy the following fields into your
.env
file:- API Key. In the
.env
file, copy the API Key into thePINATA_PINNER_KEY
variable. - API Secret. In the
.env
file, copy the API Secret into thePINATA_PINNER_SECRET
variable.
- API Key. In the
Note: Once you pass Piñata's free tier of 1GB of storage, you'll need to get access to the premium PINATA_PINNER_KEY
and PINATA_PINNER_SECRET
keys. Contact the Peel team in Discord to get access. Piñata will constantly give a 429 error if the free tier of API requests has been reached.
Juicebox uses The Graph to query the Ethereum network using a GraphQL API.
Take the following steps to set up Juicebox's subgraph for local development:
- Join Peel's discord server.
- Inquire about mainnet and Goerli subgraph URLs in the
#dev
channel. - Copy the URL into the
NEXT_PUBLIC_SUBGRAPH_URL
variable of the.env
file.
-
Run the app in dev mode
yarn dev
-
Build a production build
yarn build
-
Run a production build locally
yarn build yarn start
In development, you can simulate transactions using Tenderly. Tenderly produces a stacktrace that you can use to debug failing transactions.
Set up Tenderly for your development environment using the following steps:
-
Create a Tenderly account
-
Set the following variables in your
.env
file (without the comments):# .env NEXT_PUBLIC_TENDERLY_API_KEY= # your user tenderly api key NEXT_PUBLIC_TENDERLY_PROJECT_NAME= # your tenderly project NEXT_PUBLIC_TENDERLY_ACCOUNT= # your user account name
-
Start your development server.
yarn dev
Once set up, every transaction that you submit will be simulated using Tenderly.
When a simulation fails, an error is logged to the development console. This log contains a link to the simulation in Tenderly.
Note: there is a 50 simulation per month limit per account.