Smart Contract Interfaces
Dubhe Engine smart contracts are built using the Move programming language, providing type-safe, resource-oriented programming for blockchain applications.Component Contracts
Base Component Structure
All components in Dubhe Engine follow a standardized Move struct pattern:Component Operations
Create Component
Update Component
System Contracts
System Function Pattern
System functions operate on components and implement game logic:Event System
Event Definitions
Access Control
Permission Patterns
Error Handling
Standard Error Codes
| Code | Name | Description |
|---|---|---|
1 | EInsufficientPermission | Caller lacks required permissions |
2 | EInvalidInput | Input parameters are invalid |
3 | EResourceNotFound | Requested resource doesn’t exist |
4 | EInsufficientBalance | Insufficient balance for operation |
5 | EGameLogicViolation | Operation violates game rules |
Error Usage
Testing Patterns
Unit Test Example
Best Practices
Security Guidelines
- Always validate inputs before processing
- Use proper access controls for administrative functions
- Emit events for important state changes
- Handle edge cases explicitly
- Write comprehensive tests for all functions
Next Steps
Client SDK API
Learn to interact with contracts from frontend
Schema Definitions
Understand component data structures