Skip to content

About

Smart Contract repository for Nifty League

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

510 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Nifty League Hardhat Project

This project demonstrates an advanced Hardhat use case, integrating other tools commonly used alongside Hardhat in the ecosystem.

Setup Guide

Bun 1.4.4 is required. Type checks use bun check after Hardhat compilation and TypeChain generation. Formatting stays on Oxfmt.

Install dependencies

bun install

Setup environment variables

Copy the .env.example file in this directory to .env.local (which will be ignored by Git):

cp .env.example .env.local

Compile code

bun run build

This command uses hardhat clean to clear cache and delete all artifacts. It then runs hardhat compile to compile the entire project, building fresh artifacts.

Testing

Check code format

We use Oxfmt for TypeScript code formatting!

bun run fmt

This runs oxfmt . to write all TypeScript files. To only verify formatting use bun run format:check. Solidity files are linted with Solhint (bun run lint:sol).

Linting

For TypeScript files we use Oxlint and for Solidity files we use Solhint. You can run both with:

bun run lint

If you want to run them individually use bun run lint:ts or bun run lint:sol.

TypeScript

To check TypeScript for the entire app, run the following command:

bun run type-check

Solidity static analysis

We use Slither in our CI pipeline to check and report any potential vulnerabilities in our contracts. You can also run this analyzer locally which will generate a SLITHER.md report. Run the following:

bun run slither

Hardhat tests

Please write tests for all contracts in the src/test/ folder. To run all use:

bun run test

You can also run a single test using:

hardhat test src/test/{desired_test_script}.test.ts --typecheck --network hardhat

Note: All tests should be run on hardhat network!

Deploying contracts

For deployment we use the hardhat-deploy plugin. This plugin allows you to write deploy scripts in the src/deploy folder and declare nested deploy environments. Each deploy script in the selected build environment will run sequentially.

Note: Local & Testnet networks are all configured to use an account PRIVATE_KEY defined in .env while mainnet networks are configured to check for Ledger. You can quickly change these settings in hardhat.config.ts defining accounts or ledgerAccounts.

Local Development:

Start a JSON-RPC server on top of Hardhat Network:

npx hardhat node

Deploy test contracts on Hardhat Network (this will deploy scripts sequentially in src/deploy/hardhat):

bun run deploy:hardhat

Tenderly DevNet:

To use DevNets, go to Tenderly and spawn a new DevNet. You will need to copy the RPC details into .env TENDERLY_DEV_NET=<slug>/<devnet-id>

You can now set ETH_NETWORK to "tenderly" or run:

bun run deploy:tenderly

Testnet:

To deploy to our preferred testnet, Sepolia:

bun run deploy:sepolia

Note: hardhat will use an account PRIVATE_KEY defined in .env

Mainnet:

For mainnet deployment we use Frame to deploy with a Ledger signer.

bun run deploy:mainnet

Export contracts

To export contracts for use in client repositories, run:

bun run export

This will create deployment files in exports/ for both mainnet & sepolia which are git-ignored.

Other scripts

Try running some of the following tasks:

npx hardhat accounts
npx hardhat compile
npx hardhat clean
npx hardhat node
npx hardhat help
npx hardhat coverage
npx hardhat run src/scripts/<script>.ts

Etherscan verification

To try out Etherscan verification, you first need to deploy a contract to an Ethereum network that's supported by Etherscan.

Copy the .env.example file to a file named .env, and then edit it to fill in the details. Enter your Etherscan API key, your node URL (eg from Alchemy), and the private key of the account which will send the deployment transaction. With a valid .env file in place, first follow the instructions above to deploy your contract(s).

Verify all deployments

To verify all deployments on your selected network, run:

bun run verify

This will use the etherscan-verify script from hardhat-deploy to quickly verify all deployments!

  • npx hardhat --network {network} etherscan-verify --api-key {etherscan_api_key}

Verify specific deployment

If you instead want to target a specific deployment to verify:

Then, copy the deployment address and paste it in to replace DEPLOYED_CONTRACT_ADDRESS in this command:

bun run hardhat verify --network {network} DEPLOYED_CONTRACT_ADDRESS

Verification issues?

You can try flattening the contract source code to manually submit for verification:

bun run hardhat flatten src/contracts/Foo.sol > Flattened.sol

Performance optimizations

For faster runs of your tests and scripts, consider skipping ts-node's type checking by setting the environment variable TS_NODE_TRANSPILE_ONLY to 1 in hardhat's environment. For more details see the documentation.

Support

Email andy@niftyleague.com

or

Join the Nifty League Discord Server and message a admin

About

Smart Contract repository for Nifty League

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages