-
Create a fork of this repository.
-
Clone your fork and navigate to the root directory.
-
Install project dependencies.
yarn install
-
Create a
.envfile in the root directory which mirrors the.example.envfile. Learn how to define each field in the.envfile 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
.envfile, copy the Project ID into theNEXT_PUBLIC_INFURA_IDvariable. - 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
.envfile, copy the network name (e.g. 'mainnet', not the url) into theNEXT_PUBLIC_INFURA_NETWORKvariable.
- 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
.envfile, copy the Project ID into theINFURA_IPFS_PROJECT_IDvariable. - API KEY SECRET. In the
.envfile, copy the API KEY SECRET into theINFURA_IPFS_API_SECRETvariable. - DEDICATED GATEWAY SUBDOMAIN. In the
.envfile, copy the DEDICATED GATEWAY SUBDOMAIN into theNEXT_PUBLIC_INFURA_IPFS_HOSTNAMEvariable 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
.envfile:- API Key. In the
.envfile, copy the API Key into thePINATA_PINNER_KEYvariable. - API Secret. In the
.envfile, copy the API Secret into thePINATA_PINNER_SECRETvariable.
- 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
#devchannel. - Copy the URL into the
NEXT_PUBLIC_SUBGRAPH_URLvariable of the.envfile.
-
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
.envfile (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.