Inside contracts you are going to find:
- contracts: all the developed contracts
- deployments: resultant ABI and info for deployments (each network will have a nested folder)
- lib: external modules used by Foundry
- scripts: any utility scripts used for interacting with deployed contracts
- test: tests suits to validate contracts
And after running it locally some folders may be generated:
artifacts
: ABIs and build info generated by Hardhatcache
: cache info used by Hardhatforge-cache
: cache info used by Foundrynode_modules
: all dependencies for the Node.js environmentout
: resultant ABIs for all contracts that has interactions
The contracts present in this project are based in Solidity and it uses Node.js for running scripts and yarn to keep dependencies management.
⚠️ Before starting developing make sure you Solidity, Node.js and yarn correctly installed in your environment
Also, make sure you run yarn
at the root directory to get some required tools. The rest of these steps assume you are in the contracts folder.
Follow the steps:
-
Clone the repo, check out how here.
-
Install dependencies:
$ yarn
-
Compile the contracts to make sure everything is correct:
$ yarn compile
The output should looks like:
yarn run v1.22.19 $ hardhat compile Compiled 14 Solidity files successfully. Done in 0.98s.
-
Now you are able to make your code changes in the project. To help with Solidity, check the language references.
The project is covered with test suits (Foundry & Hardhat) that must pass to guarantee code integrity.
All HardHat tests are located at this directory.
-
Make sure that you have the dependencies installed:
$ yarn
-
Run:
$ yarn test:hardhat
The output should finish looking like:
... 33 passing (1s) Done in 2.11s.
All Forge tests are located at this directory.
In order to run them, you need to have Forge by Foundry installed on your machine (check this installation guide).
It is also required for you to have forge-std in your ./lib/
directory. In case you don't have it yet, you can run:
$ git submodule update --init --recursive
After installing Foundry and its components, you can simply run in the root directory:
$ yarn test:foundry
It is going to execute all test cases that are described in the test/foundry directory. Your output should looks like:
Test result: ok. 36 passed; 0 failed; finished in 4.06ms
Done in 0.58s.
Alternatively, you can run both test environments by executing:
$ yarn test
⚠️ Please make sure to update tests as appropriate before pushing code
This guide contains instructions to deploy the contract on three networks. If the execution is successful, you will see the contract address on your screen at the end of the instructions.
HardHat offers a local testnet environment that allows users and testers to deploy and interact with contracts without the need to contact external APIs and endpoints.
To start your local HardHat network, you need to run a node first. It is important to not terminate the command before proceeding with the instructions:
$ yarn node:hardhat
To deploy the contract on the HardHat network, execute:
$ yarn deploy:hardhat
If the execution is successful, you will see the contract address on your screen.
To deploy the contract on the testnet, you have to first export your wallet's private key and update the .env.example
file at the root directory of this repository.
The .env.example file needs to be renamed to .env
before continuing. Make sure you are using your private API URL, if you have one.
After updating the .env
file, you can deploy the contract by following the guides below.
Run:
$ yarn deploy:mumbai
to deploy the contract on the testnet. Please note that your wallet needs to hold enough Mumbai MATIC for the deployment to be successful. To reach more in-depth information about how to deploy contract checkout this guide.
Run:
$ yarn deploy:sepolia
to deploy the contract on the testnet. Please note that your wallet needs to hold enough Sepolia ETH for the deployment to be successful. To reach more in-depth information about how to deploy contract checkout this guide.
Run:
$ yarn deploy:goerli
to deploy the contract on the testnet. Please note that your wallet needs to hold enough Goerli ETH for the deployment to be successful.
For any of the deploy scripts above you are able to input arguments to change the date sent during the deployment. They are:
Argument | Description | Example | Default |
---|---|---|---|
--new-proxy-instance | Force to deploy a new proxy instance | --new-proxy-instance | false |
--name | The collection name | --name "Fleek NFAs" | FleekNFAs |
--symbol | The collection symbol | --symbol "FKNFA" | FLKNFA |
--billing | The billing values in an array of numbers | --billing "[10000, 20000]" | [] |
Appending all of them together would be like:
$ yarn deploy:hardhat --new-proxy-instance --name "Fleek NFAs" --symbol "FKNFA" --billing "[10000, 20000]"
Right away, in the scripts folder you are able to see some scripts that will help you to interact with deployed contracts. By default you are able to select localhost
, hardhat
, mumbai
, sepolia
or goerli
network name predefined on hardhat.config.ts. The scripts will be using the deployment information stored in the deployments folder. You should have a nested folder for each of the networks you have deployed it. The scripts needs be run using the Hardhat environment following the pattern:
# Replace <script_name> with the selected script
# Replace <network_name> with the selected network
$ npx hardhat run scripts/<script_name>.js --network <network_name>
💡You are able to see and change the arguments for each script at the top of each file