Get ready-to-use Foundry projects directly from https://www.cookbook.dev
Please follow these steps, if you all ready have Foundry setup ignore steps 1 and 2
Step 1: Install Rust https://doc.rust-lang.org/book/ch01-01-installation.html
Step 2: Install Foundry https://book.getfoundry.sh/getting-started/installation#using-foundryup
Step 3: Build
Please run the command below to build your contracts
forge build
If you get a stack to deep error try running the command below
forge build --via-ir
Step 4: Test
Please run the command below to test your contracts, the given tests are examples please generate your own.
forge test
Step 5: Deploy
First populate the .env file with your enviroment variable values.
Please run the command below in your terminal to define your enviroment variables globally and deploy your contracts. The given script contract is an example please generate your own.
source .env
Then run the command below to deploy your contracts, make sure to replace the CONTRACT_FILENAME with the contract script file name and the CONTRACT_NAME with the script contract's name.
forge script script/CONTRACT_FILENAME:CONTRACT_NAME --rpc-url $GOERLI_RPC_URL --broadcast --verify -vvvv
Example: forge script script/contract.s.sol:ContractScript --rpc-url $GOERLI_RPC_URL --broadcast --verify -vvvv