How sarvagnakadiya/earnkit-contracts works
Project Type and Purpose
• This is a blockchain smart contract project that relies on Foundry. The primary purpose is to manage campaign contracts, deploy tokens with integrated campaigns, and handle protocol rewards, among others.
• The README clearly details multiple deployment scenarios (campaign deployment, earnkit & LpLocker, and campaign-linked token deployment) along with specific instructions for interacting with the deployed contracts on different networks like Sepolia and Mainnet.
File Structure and Key Components
• Smart Contracts and Source Code (src):
• The src directory includes modules like Interfaces, coinvise (with a submodule for protocol-rewards), and libraries.
• This is where the core business logic for the different contracts (campaign, earnkit, token management, rewards, etc.) is defined.
• ABI Files (abi):
• Contains JSON artifacts for various contracts (Campaigns, Earnkit, EarnkitToken, LpLocker, ProtocolRewards, RewardsSplitter) that reflect the compiled interface of each smart contract.
• Deployment Scripts (script):
• Contains shell scripts (deploy-campaign.sh, deploy-token-with-campaign.sh, deploy.sh) that handle the orchestration of contract deployments.
• Testing (test):
• Houses mocks and test files, which can detail interactions via Foundry tests to ensure contract functionality.
• Dependencies/External Libraries (lib):
• Includes third-party libraries like OpenZeppelin, Foundry’s forge-std, and v3-core. These are integral to secure and standard-compliant smart contract development.
• Foundry Setup (foundry.toml and other CLI instructions in the README):
• The build, test, formatting, and script execution commands in the README reiterate the reliance on Foundry’s toolset.
Main Components
a. Smart Contracts (Core Components):
• Campaign Contract
• Earnkit Contract & EarnkitToken
• ProtocolRewards Contract
• LpLocker Contract
• RewardsSplitter (if applicable)
b. Deployment and Scripting Layer:
• Deployment Scripts (deploy-campaign.sh, deploy.sh, deploy-token-with-campaign.sh)
• Environment Configuration (.env file and its role in setting addresses like CAMPAIGN_CONTRACT_ADDRESS)
c. Testing and Development Tools:
• Foundry Tools (Forge, Cast, Anvil, Chisel) as supporting components
d. External Dependencies:
• Libraries such as OpenZeppelin Contracts, forge-std, and v3-core (used for secure contract patterns and standards)
Relationships and Interactions
• The deployment scripts interact directly with the smart contract code in the src directory by orchestrating the deployment process.
• The ABI directory is the output of the compile process and is used for interacting with already-deployed contract instances.
• Testing utilizes both the smart contract source code and mocks from the test directory to simulate and verify expected behaviors.
• Environment variables (from .env) enable configuration of deployment parameters (for example, setting the campaign contract address).
• Foundry’s ecosystem underpins the entire workflow from development and testing (Forge, Anvil) to deployment and verification.
Architectural Patterns or Design Principles
• Modularization: The separation of contracts into individual responsibilities with distinct modules (campaign, earnkit, protocol rewards) is clearly visible.
• Separation of Concerns: The division between development (src, test), deployment (script), and external dependencies (lib) enhances maintainability.
• CI/CD Integration: The presence of the .github/workflows directory indicates automated testing (e.g., test.yml) and possible continuous integration.