Skip to content

IpastorSan/foundry-template

Repository files navigation

Foundry Template

Instructions.

Assuming you already have Rust and Foundry installed.

See the Book of Foundry to learn more.

forge install
  1. Compile the project
forge build
  1. Run test suite
forge test

Generate docs based on Natspec on files

forge doc

Check test coverage

forge coverage

Run Foundry formater

forge fmt

Get all functions selectors from a contract

forge inspect <YourContractName> methods

Run Locally

Open Anvil local node

anvil

Safely store your private keys

Encryption using ERC2335

In the forge console:

  1. Open the interactive console to import your private key
cast wallet import <KEYNAME> --interactive
  1. Paste your private key in the prompt
  2. Input a password for that key (remember, a safe and brand-new one. REMEMBER it)

See all stored keys

cast wallet list

Use it in your scripts like I do on the following scripts

View the full video from Patrick Collins for Cyfrin if it's not clear

Load .env variables (Use for everything BUT your private keys)

Load .env variables in .env file->NO spaces between variable name and value, value with quotes. ETHERSCAN_KEY="blablabla"

source .env

Run on local node Note --sender is the public address of your private key

forge script script/DeployLocal.s.sol:Deploy --fork-url http://localhost:8545 --account <PRIVATE_KEY_NAME> --sender <ACCOUNT_ADDRESS> --broadcast -vvvv

Deploy to Sepolia

Deploy to Sepolia and verify. Note --sender is the public address of your private key

forge script script/DeployTestnet.s.sol:Deploy --rpc-url $SEPOLIA_KEY  --account <PRIVATE_KEY_NAME> --sender <ACCOUNT_ADDRESS> --broadcast --verify --etherscan-api-key $ETHERSCAN_KEY -vvvv

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published