The Tokens Service provides advanced operations on tokens that extend beyond basic UTXO management. There are two primary layers: a high-level API for cryptographic de-obfuscation and an internal service for managing local state synchronization.
token/services/tokens)The internal Service is responsible for managing the local representation and lifecycle of tokens. It bridges the gap between ledger-level UTXOs and application-level wallet state.
TokenDB to reflect the ledger’s state (marking tokens as spendable, pending, or deleted). See storage.go.events.Publisher) when tokens are added or removed.PruneInvalidUnspentTokens).Panurus supports multiple cryptographic representations simultaneously using Type IDs:
| Representation | Location | Type ID | Description |
|---|---|---|---|
| Fabtoken | core/fabtoken | 1 |
Cleartext: Tokens where type, value, and owner are directly visible. |
| Comm | core/comm | 2 |
Commitment: Uses Pedersen commitments (math.G1) to hide details while maintaining provability. |
While the internal service manages de-obfuscated state, the actual cryptographic “unscrambling” is handled by the TokensService interface (which wraps the underlying driver).
Privacy-preserving drivers like zkatdlog hide token details on the ledger. To reveal them, the Deobfuscate method is used:
This is critical for:
lazy.Provider for on-demand initialization per TMS.RequestsCache stores pending requests and pre-extracted actions to optimize performance during transaction commitment.tokendb implementation for persistent UTXO tracking.graph TD
User[Service / Application] --> HighAPI[token.TokensService]
HighAPI --> Driver[Token Driver]
User --> InternalSvc[tokens.Service]
InternalSvc --> TokenDB[(TokenDB)]
InternalSvc --> Net[Network Service]
subgraph "Internal Logic"
InternalSvc -- "Uses de-obfuscated data" --> State[State Sync]
State --> Cache[Ristretto Cache]
end