π€Useful Commands
π¨AnvilπͺCastπ₯Forge
Run Scripts
forge build
forge script script/<SCRIPT>:<CONTRACT_NAME> --rpc-url http://<RPC_URL>
forge script script/<SCRIPT>:<CONTRACT_NAME> --fork-url http://<RPC_URL>
Foundry DevOps
A repo to get the most recent deployment from a given environment in Foundry. This way, you can do scripting off previous deployments in solidity.
forge install Cyfrin/foundry-devops --no-commit
import {DevOpsTools} from "lib/foundry-devops/src/DevOpsTools.sol";
import {MyContract} from "my-contract/MyContract.sol";
function interactWithPreviouslyDeployedContracts() public {
address contractAddress = DevOpsTools.get_most_recent_deployment("MyContract", block.chainid);
MyContract myContract = MyContract(contractAddress);
myContract.doSomething();
}
Makefile
@
stops the command being printed out to the command line which is useful when you don't want sensitive info to be printed e.g. private keys.
-include .env
build:; forge build # ; is used to run multiple commands in one line
deploy-holesky:
forge script script/DeployFundMe.s.sol:DeployFundMe --rpc-url $(HOLESKY_RPC_URL) --private-key $(HOLESKY_PRIVATE_KEY) --broadcast -vvvv
deploy-holesky-verify:
forge script script/DeployFundMe.s.sol:DeployFundMe --rpc-url $(HOLESKY_RPC_URL) --private-key $(HOLESKY_PRIVATE_KEY) --broadcast --verify --etherscan-api-key $(ETHERSCAN_API_KEY) -vvvv
Last updated