Skip to content

XueDAOTW/24-frontend-workshop-contract-template

Repository files navigation

24-frontend-workshop-contract-template

This is a template for the 24 frontend workshop contract.

Getting Started

  1. 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
  1. 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
  2. Build the contracts:

$ forge build
  1. 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
  2. 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/")

Common Usage

This is a list of the most frequently needed commands.

Build

Build the contracts:

$ forge build

Clean

Delete the build artifacts and cache directories:

$ forge clean

Compile

Compile the contracts:

$ forge build

Coverage

Get a test coverage report:

$ forge coverage

Deploy

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

Format the contracts:

$ forge fmt

Gas Usage

Get a gas report:

$ forge test --gas-report

Test

Run the tests:

$ forge test

Generate test coverage and output result to the terminal:

$ pnpm test:coverage

Related Efforts

License

This project is licensed under MIT.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published