Developer Setup
Ocean Protocol uses Foundry for smart contract development with a comprehensive testing and deployment framework.
Prerequisites
Core Requirements
Foundry: Latest version for contract compilation and testing
Node.js: v18+ for tooling and scripts
Git: For repository management
Code Editor: VS Code with Solidity extensions recommended
Optional Tools
bun: Fast package manager and script runner
Docker: For containerized development
Hardhat: Alternative testing framework (if needed)
Environment Setup
1. Clone Repository
2. Install Dependencies
3. Environment Configuration
Development Commands
Contract Development
Testing Framework
Linting and Quality
Testing Strategies
Unit Testing
Integration Testing
Fork Testing
Deployment
Local Development
Testnet Deployment
Mainnet Deployment
Debugging and Troubleshooting
Common Issues
Compilation Errors
Test Failures
Gas Optimization
Development Tools
Foundry Debugger: Step-through debugging for failed transactions
Trace Analysis: Detailed execution traces for complex transactions
Storage Layout: Analyze contract storage for optimization
Best Practices
Code Quality
Follow Ocean's coding standards
Use consistent naming conventions
Implement comprehensive error handling
Add detailed natspec documentation
Security
Always inherit from BaseHandler for handlers
Use OpenZeppelin's security libraries
Implement proper access controls
Add reentrancy protection where needed
Testing
Aim for >95% test coverage
Test both success and failure cases
Include edge case testing
Use fuzz testing for parameter validation
Gas Optimization
Use efficient data structures
Minimize external calls
Batch operations when possible
Profile gas usage regularly
Contributing
Pull Request Process
Fork the repository
Create feature branch
Implement changes with tests
Ensure all tests pass
Submit pull request with description
Code Review Requirements
All tests must pass
Code coverage must be maintained
Security review for handler changes
Documentation updates where needed
This development environment provides everything needed to build, test, and deploy Ocean Protocol contracts and handlers efficiently.
Last updated