Utilities
This section provides an overview of the helper functions and modules available in the Blocklet SDK. These utilities are designed to streamline common development tasks, including secure wallet operations, accessing environment configurations, facilitating internal API communication, and understanding the core data structures.
For detailed information on each utility, refer to the following sub-sections:
Wallet & Security Management#
The Blocklet SDK includes a suite of tools for managing your Blocklet's internal wallet and performing cryptographic operations. These utilities enable secure interactions, such as signing and verifying data, and handling encrypted information.
Key functionalities include:
- Wallet Access: Obtain the Blocklet's wallet instance for various operations.
- Data Encryption/Decryption: Securely encrypt and decrypt sensitive data using Blocklet's keys.
- Signature Verification: Ensure the integrity and authenticity of data through digital signatures.
Explore these capabilities further in the Wallet Management section.
Environment & Configuration Access#
Effective Blocklet development requires seamless access to runtime environment variables and application-specific configurations. The SDK provides a centralized env
object and config
module that expose crucial information about your Blocklet and the Blocklet Server it runs on.
This includes:
- Environment Variables: Direct access to all Blocklet and Blocklet Server related environment variables.
- Application Configuration: Access to dynamic configurations, such as installed components, theme settings, and Blocklet lifecycle information.
- Server Versioning: Utilities to check and compare the current Blocklet Server version.
For a comprehensive guide, see Environment & Config.
Internal API Clients#
For Blocklets to securely communicate with the Blocklet Server and other deployed components, the SDK offers specialized API clients. These clients automatically handle authentication and signature mechanisms, ensuring secure and reliable internal calls.
Key clients discussed are:
componentApi
: For making secure API calls to other Blocklet components.serviceApi
: For interacting with the core Blocklet Service APIs.
Learn how to leverage these clients for inter-service communication in API Clients.
Constants & Type Definitions#
Consistency across the Blocklet ecosystem is maintained through a set of shared constants and comprehensive TypeScript type definitions. These definitions originate from Blocklet Server's protobuf schemas and internal validation rules, providing a clear contract for data structures and API interactions.
This section covers:
- Global Constants: Important values used throughout the Blocklet Server environment.
- Protocol Buffer Types: Detailed TypeScript interfaces for various Blocklet Server entities (e.g., node state, Blocklet metadata, user information, notification structures).
- Validation Schemas: Insights into the validation rules for common data payloads.
Refer to Constants & Types for a complete reference.
Conclusion#
The utilities provided by the Blocklet SDK are essential for building robust and secure decentralized applications on Blocklet Server. By offering streamlined access to core functionalities like wallet management, configuration, and internal communication, the SDK empowers developers to focus on application logic rather than underlying infrastructure concerns.
Continue exploring the detailed sub-sections to fully leverage these powerful utilities in your Blocklet development: