A nifty marketplace for NFTs
Nifty is an Ethereum smart contract that allows users to list and buy NFTs. It also has an indexed subgraph deployed on The Graph Network to enable rich GraphQL queries.
1. Install and start Docker
2. Install dependencies
npm install --force
3. Create a .env
file
Add the following environment variables:
GOERLI_RPC_URL
- Using Alchemy is recommendedDEPLOYER_PRIVATE_KEY
- Creating a fresh Metamask wallet just for development, without any real funds is recommendedETHERSCAN_API_KEY
- See Etherscan APICOINMARKETCAP_API_KEY
- Optional, add to output gas report prices in USD. See CoinMarketCap APISHOULD_UPDATE_FRONT_END
- Optional, add and set to true to export contract addresses and ABIs to the frontend, false otherwise
Build contracts
npm run build:contracts
Build testnet subgraph
npm run build:subgraph:staging
Build mainnet subgraph
npm run build:subgraph:production
Run linter
npm run lint
Run typechecker
npm run typecheck
Run all static checks
npm run staticcheck
Run contract unit tests
npm run test:contracts:unit
Run contract property tests
npm run test:contracts:property
Run contract assertion tests
npm run test:contracts:assertion
Run subgraph unit tests
npm run test:subgraph:unit
Run all unit tests
npm run test:unit
Run all tests
npm run test
Run all static checks and unit tests
npm run check:unit
Run all checks
npm run check
1. Install Miniconda
Miniconda helps create an isolated virtual environment and install the tools we use for security analysis.
Set up the nifty virtual environment
npm run analyze:setup
Run slither security analysis
npm run analyze:slither
Run mythril security analysis
npm run analyze:mythril
Run all security analysis tools
npm run analyze
Run a custom script
npm run script:<environment> scripts/<script>.ts
Estimate gas for a transaction
- Deploy contracts locally
npm run deploy:contracts:development
- Run
estimateGas
script
npm run script:development scripts/estimateGas.ts
Report gas usage for tests
npm run report-gas-usage
Deploy contracts locally
npm run deploy:contracts:development
Deploy contracts to testnet
npm run deploy:contracts:staging
Deploy subgraph to testnet
1) Update the subgraph's testnet Nifty contract address in subgraph/networks.json
2) Deploy the subgraph
npm run deploy:subgraph:staging
3) Increase the subgraph's version by checking it's current version on Subgraph Studio
Version Label (e.g. 0.0.1) › ...
Deploy contracts to mainnet
npm run deploy:contracts:production
Deploy subgraph to mainnet
npm run deploy:subgraph:production
Deployed contract addresses can be found under deployments/<chain>/<ContractName>.json
To enable or disable updating the frontend contract addresses and ABIs automatically, set the UPDATE_FRONT_END
environment variable in .env
to true
or false
.
graph init --studio nifty-staging
When setting up a new subgraph under the subgraphs
directory, delete the .git
submodule that is created there so that the subgraph is tracked directly rather than as a submodule.
To launch the echidna docker container in interactive mode, at -it
to the docker run
options:
docker run --rm -it -v `pwd`:/nifty ghcr.io/crytic/echidna/echidna:v2.0.4
This can let you inspect the internals of the docker container manually, and/or run echidna-test
with more friendly visual feedback.
All checks are run locally automatically before a commit is made using npm run check
.
Modify the existing pre-commit hook
Edit the .husky/pre-commit file
Add a pre-commit hook
npx husky add .husky/pre-commit "npm run check"
See the Husky Documentationto learn more on how to configure pre-commit hooks.
There is currently an issue with the "@nomiclabs/hardhat-ethers": "npm:[email protected]",
package which causes errors when trying to update or install new packages. Use --force
to override these errors.