- We have to fund the most recent deployed contract
- To get the most recent deployed
- foundry-devops package is used
forge install Cyfrin/foundry-devops --no-commit
- Update
foundry.toml
to have read permissions on the broadcast folder.
fs_permissions = [{ access = "read", path = "./broadcast" }]
- Import the package, and call
DevOpsTools.get_most_recent_deployment("MyContract", chainid)
;
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();
}