This is a template for the 24 frontend workshop contract.
- Clone the repository and navigate to the project directory:
$ git clone https://github.com/24-hack/24-frontend-workshop-contract-template.git
$ cd 24-frontend-workshop-contract-template
-
Install dependencies using
pnpm
:If you do not have
pnpm
installed, you can install it using the following command:$ npm install -g pnpm
Using
pnpm
:$ pnpm install
-
Build the contracts:
$ forge build
-
Deploy the contracts:
If you did not set up a MNEMONIC environment variable, you can use the
--private-key
flag to deploy the contracts.For general deployment:
forge script script/Deploy.s.sol \ --rpc-url <RPC_URL> \ --sig "run()" -vvv
Example using the Zircuit chain:
forge script script/Deploy.s.sol \ --rpc-url zircuit \ --legacy \ --broadcast \ --sig "run()" -vvv
-
Verify the contracts:
To verify your contracts, use the following command:
forge verify-contract \ --verifier-url <VERIFIER_URL> \ <deployed-contract-address> \ <source-file>:<contract-name> \ --etherscan-api-key <ETHERSCAN_API_KEY>
Example for Zircuit chain:
forge verify-contract \ --verifier-url https://explorer.zircuit.com/api/contractVerifyHardhat \ <deployed-mock-erc20-address> \ src/MockERC20.sol:MockERC20 \ --etherscan-api-key <ZIRCUIT-API-KEY>
forge verify-contract \ --verifier-url https://explorer.zircuit.com/api/contractVerifyHardhat \ <deployed-xue-membership-nft-address> \ src/XueMembershipNFT.sol:XueMembershipNFT \ --etherscan-api-key <ZIRCUIT-API-KEY> \ --constructor-args $(cast abi-encode "constructor(string)" "https://xuedaoisgood.com/")
This is a list of the most frequently needed commands.
Build the contracts:
$ forge build
Delete the build artifacts and cache directories:
$ forge clean
Compile the contracts:
$ forge build
Get a test coverage report:
$ forge coverage
Deploy to Anvil:
$ forge script script/Deploy.s.sol --broadcast --fork-url http://localhost:8545
For this script to work, you need to have a MNEMONIC
environment variable set to a valid
BIP39 mnemonic.
For instructions on how to deploy to a testnet or mainnet, check out the Solidity Scripting tutorial.
Format the contracts:
$ forge fmt
Get a gas report:
$ forge test --gas-report
Run the tests:
$ forge test
Generate test coverage and output result to the terminal:
$ pnpm test:coverage
- abigger87/femplate
- cleanunicorn/ethereum-smartcontract-template
- foundry-rs/forge-template
- FrankieIsLost/forge-template
This project is licensed under MIT.