Blockchain Devops
- Blockchain DevOps involves the application of DevOps principles and practices in the blockchain ecosystem. It focuses on streamlining the development, deployment, testing, and operation of blockchain-based applications or networks.
Tip : The following example is completely for learning and sharing coding experiences purpose
How we can implement the devops principle in our Blockchain project?
- We will see a simple example of how we can implement Devops in our blockchain project.
Note: We are using Foundry as our development framework. We are not going to discuss the main coding part. We will just go through the installation and requirement part!!!!
Now, we will try to get the most recent deployment from a given environment in foundry. This way, we can do scripting off previous deployments in solidity.
Download the following library and repo in your project:
forge install foundry-rs/forge-std@v1.8.2 --no-commit
forge install Cyfrin/foundry-devops --no-commit
- Update your foundry.toml to have read permissions on the broadcast folder.
fs_permissions = [
{ access = "read", path = "./broadcast" },
{ access = "read", path = "./reports" },
]
- Import the package, and call :
import {DevOpsTools} from "lib/foundry-devops/src/DevOpsTools.sol";
import {MyContract} from "my-contract/MyContract.sol";
.
. rest of your code
.
function interactWithPreviouslyDeployedContracts() public {
address contractAddress = DevOpsTools.get_most_recent_deployment("MyContract", block.chainid);
MyContract myContract = MyContract(contractAddress);
myContract.doSomething();
}
By, following the above steps in our foudry code, we can get the most recent deployed contract code
For, L2 and rollups blockchain network you can prefer the given repo