Skip to content

NFT contracts used for guild.xyz's contract call reward.

License

Notifications You must be signed in to change notification settings

guildxyz/nft-reward-factory

Repository files navigation

NFT reward factory

NFT contracts used for Guild.xyz's CONTRACT_CALL reward.

Setup

To run the project you need Node.js development environment.

Pull the repository from GitHub, then install its dependencies by executing this command:

npm install

Certain actions, like deploying to a public network or verifying source code on block explorers, need environment variables in a file named .env. See .env.example for more info.

Some additional steps before deployment

Open the script you wish to use, depending on if you want to deploy the contracts for the first time or upgrade an existing deployment. Notice the constants at the top and edit them according to your needs.

Contract deployment

To deploy the smart contracts to a network, replace [networkName] with the name of the network and [scriptName] with the name of the script you wish to run in this command:

npx hardhat run scripts/[scriptName] --network [networkName]

Networks can be configured in hardhat.config.ts. We've preconfigured the following:

  • hardhat (for local testing, default)
  • ethereum (Ethereum Mainnet)
  • goerli (Görli Ethereum Testnet)
  • sepolia (Sepolia Ethereum Testnet)
  • bsc (BNB Smart Chain)
  • bsctest (BNB Smart Chain Testnet)
  • polygon (Polygon Mainnet (formerly Matic))
  • mumbai (Matic Mumbai Testnet)
  • gnosis (Gnosis Chain (formerly xDai Chain))
  • arbitrum (Arbitrum One (Mainnet))
  • base (Base Mainnet)
  • optimism (Optimism Mainnet)
  • zksync (zkSync Era Mainnet)
  • cronos (Cronos Mainnet)
  • mantle (Mantle Network Mainnet)
  • ontology (Ontology EVM Mainnet)
  • linea (Linea Mainnet)
  • cyber (Cyber Mainnet)
  • taiko (Taiko Mainnet)
  • blast (Blast)
  • xlayer (X Layer Mainnet)
  • coredao (Core Blockchain Mainnet)
  • metis (Metis Andromeda Mainnet)
  • neon (Neon EVM Mainnet)
  • polygonzk (Polygon zkEVM)
  • scroll (Scroll)
  • zeta (ZetaChain Mainnet)
  • mint (Mint Blockchain Mainnet)
  • mode (Mode Network Mainnet)
  • avalanche (Avalanche C-Chain)
  • lisk (Lisk Mainnet)
  • form (Form Mainnet)
  • ink (Ink Mainnet)

Verification

For source code verification on block explorers, you can use the Verify plugin:

npx hardhat verify [contractAddress] [constructorArguments] --network [networkName]

For more detailed instructions, check out it's documentation here.

Some block explorers might not support the verify plugin. In that case, use hardhat-solidity-json to generate the standard JSON output and verify the contracts manually:

npx hardhat solidity-json

The generated files will be under the artifacts/solidity-json folder, which you can typically submit on block explorers.

Linting

The project uses Solhint for Solidity smart contracts and ESLint for TypeScript files. To lint all files, simply execute:

npm run lint

To lint only the Solidity files:

npm run lint-contracts

To lint only the TypeScript files:

npm run lint-ts

Tests

To run the unit tests written for this project, execute this command in a terminal:

npm test

To run the unit tests only in a specific file, just append the path to the command. For example, to run tests just for ContractName:

npm test test/ContractName.spec.ts

Documentation

The documentation for the contracts is generated via the solidity-docgen package. Run the tool via the following command:

npm run docgen

The output can be found in the docs/contracts folder.