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.
It will look through your broadcast folder at your most recent deployment.
-
Get the most recent deployment of a contract in foundry
-
Checking if you're on a zkSync based chain
Important
As of 0.3.0, nightly builds of foundry may not work as expected. Please use foundryup -v stable for the stable version of foundry.
- git
- You'll know you did it right if you can run
git --versionand you see a response likegit version x.x.x
- You'll know you did it right if you can run
- foundry
- You'll know you did it right if you can run
forge --versionand you see a response likeforge 0.2.0 (816e00b 2023-03-16T00:05:26.396218Z)
- You'll know you did it right if you can run
- jq
- A lot already have it installed. Try it with
jq --versionand see a response likejq-1.6
- A lot already have it installed. Try it with
forge install Cyfrin/foundry-devops- Update forge-std to use newer FS cheatcodes
git rm -rf lib/forge-std
rm -rf lib/forge-std
forge install foundry-rs/[email protected]
- Update your
foundry.tomlto have read permissions on thebroadcastfolder.
fs_permissions = [
{ access = "read", path = "./broadcast" },
{ access = "read", path = "./reports" },
]- Import the package, and call
DevOpsTools.get_most_recent_deployment("MyContract", chainid);
ie:
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();
}- foundry-zksync
- You'll know you did it right if you can run
foundryup-zksync --helpand you see a response like:
- You'll know you did it right if you can run
The installer for Foundry-zksync.
Update or revert to a specific Foundry-zksync version with ease.
.
.
.
In your contract, you can import and inherit the abstract contract ZkSyncChainChecker to check if you are on a zkSync based chain. And add the skipZkSync modifier to any function you want to skip if you are on a zkSync based chain.
It will check both the precompiles or the chainid to determine if you are on a zkSync based chain.
import {ZkSyncChainChecker} from "lib/foundry-devops/src/ZkSyncChainChecker.sol";
contract MyContract is ZkSyncChainChecker {
function doStuff() skipZkSync {skipZkSync: Skips the function if you are on a zkSync based chain.onlyZkSync: Only allows the function if you are on a zkSync based chain.
isZkSyncChain(): Returns true if you are on a zkSync based chain.isOnZkSyncPrecompiles(): Returns true if you are on a zkSync based chain using the precompiles.isOnZkSyncChainId(): Returns true if you are on a zkSync based chain using the chainid.
In your contract, you can import and inherit the abstract contract FoundryZkSyncChecker to check if you are on the foundry-zksync fork of foundry.
!Important: Functions and modifiers in
FoundryZkSyncCheckerare only available if you runfoundry-zksyncwith the--zksyncflag.
import {FoundryZkSyncChecker} from "lib/foundry-devops/src/FoundryZkSyncChecker.sol";
contract MyContract is FoundryZkSyncChecker {
function doStuff() onlyFoundryZkSync {You must also add ffi = true to your foundry.toml to use this feature.
onlyFoundryZkSync: Only allows the function if you are onfoundry-zksynconlyVanillaFoundry: Only allows the function if you are onfoundry
is_foundry_zksync: Returns true if you are onfoundry-zksync
For testing on vanilla foundry, run:
make testFor testing with foundry-zksync, run:
make test-zksync- You cannot deploy a contract with
FoundryZkSyncChainCheckerorZkSyncChainCheckerbecausefoundry-zksyncgets confused by a lot of cheatcodes, and doesn't recognize cheatcodes after compiling to the EraVM.
PRs are welcome!
git clone https://github.com/Cyfrin/foundry-devops
cd foundry-devops
make