packages
├── app [@popcorn/app] [next.js]
├── hardhat [@popcorn/hardhat] [solidity contracts & typechain]
├── utils [@popcorn/utils] [generic utils]
├── ui [@popcorn/ui] [ui components + storybook]
└── ... etc
-
Install packages:
curl -L https://foundry.paradigm.xyz | bash
- in packages/hardhat
foundryup
- in packages/hardhat
cargo build --manifest-path lib/utils/exporter/Cargo.toml --release
yarn install
-
Update .env
RPC_URL
is used to run a local node and can be set tohttp://localhost:8545
FORKING_RPC_URL
is used to run fork tests and deploy contracts on a historic state of the chain. Create a free Alchemy account and use their API or use your own node.INFURA_PROJECT_ID
is used to fetch data for the frontend. A paid multichain Infura account is needed.CHAIN_ID
is the default chainId used by the frontend and should usually be1337
for local development.
-
Add Metamask to your browser
-
Enable test-networks in Metamask
-
Add the Hardhat Signer with private key
0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
to Metamask. This account gets all the demo funds and should be used to test the app in local development. IMPORTANT - use this account only for local development as all funds can be stolen from this account
- To start a local ethereum environment and deploy all required contracts with demo data navigate into
packages/hardhat
and run:
yarn hardhat node --network hardhat
- Then in another terminal go into
packages/app
and start the app with
yarn run dev
Go to packages/app
-
Install packages
yarn install
-
Run dev (watch files and start up frontend)
yarn run dev
-
Start storybook (optional):
yarn run story
To run tests:
go to packages/hardhat
and run
yarn hardhat test
Deploy from packages/hardhat
:
- compile:
yarn compile
- and run :
yarn hardhat node --network [network]
Service | Location |
---|---|
Next.js Frontend | http://localhost:3000 |
Hardhat node | http://localhost:8545 |
Storybook | run: yarn lerna run story |
Command | Description |
---|---|
yarn install |
equivalent to npm install |
yarn add @org/packagename |
equivalent to npm install - will add to dependencies |
yarn add @org/packagename -D |
equivalent to npm install --save-dev - will add to devDependencies |
yarn clean |
cleans contract artifacts which are used to create typechain interfaces. |
Metamask Nonce is too high - When running a hardhat node and interacting with the frontend you might run into the issue that Metamasks Nonce is too high for a transaction. In this case you have to reset your Metamask. Go to Settings->Advanced->Reset Account. Dont worry this just causes metamask to refetch all data from chain and doesnt temper with any funds or other settings
I want to reset on-chain data - Simply stop your hardhat node and rerun the deploy script. The chain is completly reset to its base state with demo data. Dont forget to reset your metamask accoutn though.
Unrecognized Contract/Selector - If the frontend gives you this error your typechain types might be off or the addresses used by the frontend are wrong.
Run yarn clean
and rerun the node to recompile all contracts and generate new types. If this doesnt help, check in your terminal which contracts are causing the issue. Sometimes the address of a contract change on local development (usually after changes to the contract). In this case update the address of the contract in the file getNamedAccounts.ts
. All addresses of deployed contracts are printed in the beginning of the deploy script.
Contributions are welcome! Please raise a pull request with your contributions.
Popcorn follows the Contributor Covenant Code of Conduct.