Sui Framework
Sui Framework is a default dependency set in the Package Manifest. It depends on the Standard Library and provides the Sui-specific functionality: storage operations, native types, and the modules the rest of this chapter is built on.
For convenience, we grouped the modules in the Sui Framework into multiple categories. But they're still part of the same framework.
Core
| Module | Description | Chapter |
|---|---|---|
| sui::address | Adds conversion methods to the address type | Address |
| sui::transfer | Implements the storage operations for Objects | Storage Functions |
| sui::tx_context | Contains the TxContext struct and methods to read it | Transaction Context |
| sui::object | Defines the UID and ID type, required for creating objects | UID and ID |
| sui::derived_object | Allows UID generation through key derivation | UID Derivation |
| sui::clock | Defines the Clock type and its methods | Epoch and Time |
| sui::dynamic_field | Implements methods to add, use and remove dynamic fields | Dynamic Fields |
| sui::dynamic_object_field | Implements methods to add, use and remove dynamic object fields | Dynamic Object Fields |
| sui::event | Allows emitting events for offchain listeners | Events |
| sui::package | Defines the Publisher type and package upgrade methods | Publisher |
| sui::display | Implements the Display object and ways to create and update it | Display |
Collections
| Module | Description | Chapter |
|---|---|---|
| sui::vec_set | Implements a set type | Collections |
| sui::vec_map | Implements a map with vector keys | Collections |
| sui::table | Implements the Table type and methods to interact with it | Dynamic Collections |
| sui::linked_table | Implements the LinkedTable type and methods to interact with it | Dynamic Collections |
| sui::bag | Implements the Bag type and methods to interact with it | Dynamic Collections |
| sui::object_table | Implements the ObjectTable type and methods to interact with it | Dynamic Collections |
| sui::object_bag | Implements the ObjectBag type and methods to interact with it | Dynamic Collections |
Coins and Assets
| Module | Description | Chapter |
|---|---|---|
| sui::balance | The Balance type - the underlying store of value | Balance and Coin |
| sui::coin | The Coin type - a transferable fungible asset | Balance and Coin |
| sui::sui | The SUI coin type | Balance and Coin |
| sui::pay | Helper functions for splitting and merging coins | - |
| sui::deny_list | Deny list for regulated coin types | - |
| sui::token | The closed-loop token standard | - |
Utilities
| Module | Description | Chapter |
|---|---|---|
| sui::bcs | Implements the BCS encoding and decoding functions | Binary Canonical Serialization |
| sui::borrow | Implements the borrowing mechanic for borrowing by value | Hot Potato |
| sui::hex | Implements the hex encoding and decoding functions | - |
| sui::random | The Random object and secure onchain randomness | Randomness |
| sui::types | Provides a way to check if the type is a One-Time-Witness | One Time Witness |
The framework also contains modules not covered in this book: the commerce primitives (sui::kiosk, sui::transfer_policy), a set of cryptographic functions (sui::hash, sui::ed25519, sui::bls12381, and others), and assorted utilities such as sui::url and sui::versioned. Refer to the framework documentation for the full list.
Exported Addresses
Sui Framework exports two named addresses: sui = 0x2 and std = 0x1 from the std dependency.
Implicit Imports
Just like with Standard Library, some of the modules and types are imported implicitly in the Sui Framework. This is the list of modules and types that are available without explicit use import:
- sui::object
- sui::object::ID
- sui::object::UID
- sui::tx_context
- sui::tx_context::TxContext
- sui::transfer
Source Code
The source code of the Sui Framework is available in the Sui repository.