Contracts
This section covers everything related to the on-chain Move layer of a Dubhe DApp.
Read the pages in order — each one builds on the previous:
| # | Topic | What it covers |
|---|---|---|
| 1 | Resources | Declare on-chain data as resources in dubhe.config.ts, run generate, and use the generated storage APIs |
| 2 | Error Handling | Define typed errors in config; use assertion helpers in system contracts |
| 3 | Systems | Write business logic — entry function anatomy, five system patterns, guard order, deploy_hook |
| 4 | Access Control | DappKey namespace isolation, public(package) write restriction, version/pause/admin guards |
| 5 | DApp Admin | Metadata, two-step ownership transfer, emergency pause, credit top-up |
| 6 | Storage Fees | How write fees are calculated, lazy settlement, and how to top up a DApp’s credit balance |
| 7 | Testing | Unit test patterns, multi-caller scenarios, and #[expected_failure] |
| 8 | Upgrading | Add new resources, bump versions, block stale packages, and register upgrades on-chain |
| — | Address System | Multi-chain address utilities — only needed for Dubhe Channel cross-chain integration |
What is the on-chain layer?
A Dubhe DApp consists of two layers:
dubhe.config.ts → generate → sources/codegen/ ← data layer (auto-generated)
sources/systems/ ← logic layer (you write this)
│
▼
Dubhe Framework (on-chain, already deployed)You write code in two places:
dubhe.config.ts— declare what data your contract stores (resources, enums, errors)sources/systems/— write business logic using the generated resource APIs
Everything else — storage, events, fee metering, versioning — is handled by the Framework automatically.