This guide covers everything you need to contribute to the smart contracts.
# Clone your fork
git clone https://github.com/your-username/elata-protocol
cd elata-protocol
# Install dependencies and git hooks
make install
# Build contracts
make build
# Run tests
make testThe make install command sets up pre-commit hooks that format code and run tests before each commit.
Use descriptive names with prefixes:
feature/add-emergency-withdraw
fix/voting-power-calculation
docs/update-deployment-guide
test/add-lotpool-fuzz-tests
Edit contracts in src/, add tests in test/. Run tests frequently:
# Quick test run
forge test
# Test specific contract
forge test --match-contract VeELTATest
# Test with gas report
make gas-report
# Run all CI checks
make cimake fmt # Format code
make fmt-check # Check formatting without changesfeat(token): add burn functionality
fix(staking): correct boost calculation for edge case
docs(readme): update deployment instructions
test(lotpool): add fuzz tests for voting
refactor(apps): extract deployment library
Include in your PR description:
- What changed and why
- How to test it
- Any breaking changes
See STYLE.md for comprehensive NatSpec conventions and formatting standards.
Follow the Solidity Style Guide:
// Use explicit imports
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
// Document public functions with NatSpec
/**
* @notice Creates a new staking position
* @param amount ELTA tokens to lock
* @param duration Lock duration in seconds
* @return positionId The ID of the created position
*/
function createLock(uint256 amount, uint256 duration) external returns (uint256 positionId) {
// Implementation
}Name tests descriptively:
function test_CreateLock_WithMinDuration() public { }
function test_CreateLock_RevertWhen_AmountIsZero() public { }
function testFuzz_CreateLock_AnyValidDuration(uint256 duration) public { }Test both success paths and revert conditions. Add fuzz tests for functions with numeric inputs.
Use custom errors instead of require strings:
// In src/utils/Errors.sol
error AmountTooLow();
error LockExpired();
// In contract
if (amount < MIN_AMOUNT) revert Errors.AmountTooLow();src/
├── staking/VeELTA.sol # Vote-escrowed staking
├── experience/ElataPoints.sol # Reputation system
├── governance/ # Governor, timelock, funding
├── rewards/ # Fee distribution
├── apps/ # App token framework
├── fees/ # Fee routing infrastructure
├── modules/ # Airdrops, referrals
├── vesting/ # Token vesting contracts
└── utils/Errors.sol # Shared error definitions
lib/ELTA/ # ELTA token (external dependency)
test/
├── token/ELTATest.t.sol # Unit tests per contract
├── staking/VeELTATest.t.sol
├── integration/ # Cross-contract tests
└── fuzz/ # Property-based tests
script/
├── Deploy.sol # Main deployment script
└── SeedLocalData.s.sol # Local test data seeding
Before pushing, run the same checks CI will run:
make ciThis runs:
forge fmt --check— formatting checkforge build— compilationforge test— all tests- Gas report generation
When modifying contracts:
- Use OpenZeppelin contracts where possible
- Add reentrancy guards to functions that transfer tokens
- Validate all inputs (zero addresses, array lengths, bounds)
- Consider edge cases in math operations
- Add access control to admin functions
- Write tests for the security properties you're relying on
See SECURITY.md for our security policy and vulnerability reporting process.
If you find a security vulnerability:
- Do not open a public issue
- Email security@elata.bio with details
- Allow time for a fix before disclosure
- Check existing GitHub Issues
- Read the architecture docs
- Ask in the community Discord
Significant contributions may be eligible for:
- ELTA token grants
- Recognition in release notes
- Contributor role in the community
Thanks for contributing.