Contract (Instance)¶
On Concordium, a contract refers to a deployed instance of a module. Each instance has its own address <index,subindex>
and can maintain state independent of other deployments of the same module.
Representation¶
- gRPC:
CCD_ContractAddressandCCD_InstanceInfo. - MongoDB:
MongoTypeInstancedocuments stored in theinstancescollection. - Canonical ID:
<index,subindex>string that is also used when composing token addresses (<index,subindex>-token_id).
Each instance records:
- Source module reference (with versioning between v0/v1 structures).
- Named entrypoints (receive functions) and current state hash.
- Optional links to recognized projects (set by ms_instances).
Lifecycle¶
- A user submits an account transaction with effect
contract_initialized, referencing a module hash. - The
ms_block_analyserservice detects the effect and publishes acontracttask. ms_instancesconsumes the task, resolves full instance info via gRPC, persists it to MongoDB, and tries to associate it with a recognized project/module.- Subsequent
contract_update_issuedtransactions trigger upgrades;ms_instancesrecords the new module linkage and emits notifications.
Where contracts are used¶
- The Explorer UI links instances to their parent modules and displays their receive methods.
- Token accounting (
ms_token_accounting) uses contract addresses to derive CIS-2 token addresses and track holders. - Alias-aware lookups collapse contract references via the canonical
<index,subindex>format, aligning with how we process account aliases.***