Skip to content
VladyslavLapin edited this page May 7, 2024 · 1 revision

The Vara SDK for Unity includes several key scripts and components, each with a specific purpose to enhance your development experience:

  • LogManager.cs

The LogManager serves as the initializer for the Serilog logging system within a Unity environment. Its primary role is to configure and set up Serilog upon the start of the Unity application

  • UnityConsole.cs

The UnityConsole contains two critical components for integrating Serilog with Unity's logging system: UnityConsoleSink and UnityConsoleSinkExtensions.

  • UnityMainThreadDispatcher.cs

Facilitates thread-safe execution of tasks on Unity's main thread, essential for updating UI elements in response to external callbacks.

  • Singleton.cs

A generic implementation of the singleton pattern for MonoBehaviours, ensuring a single instance of a class.

  • CachingManager.cs

Handles file operations, particularly for wallet-related functionalities within the Substrate .NET Wallet library.

  • NetworkManager.cs

Manages connections to blockchain nodes and wallet integration, ensuring stable network communication.

  • StorageManager.cs

Responsible for polling blockchain storage, providing a consistent and updated view of on-chain data.

  • ScreenStateMachine.cs

A utility for managing UI state transitions, useful for handling different screens or UI elements in response to user interactions or data changes.

Main Classes

The Vara SDK for Unity includes several crucial classes that serve as foundational elements for blockchain development. While detailed documentation can be found in their respective repositories, here's a brief overview of some key classes:

  • Account

Manages cryptographic keys and supports essential operations like signing and verifying messages, crucial for maintaining security in blockchain transactions.

  • SubstrateClient

A central class for interacting with the Substrate blockchain, providing various functionalities like data handling and module access.

  • Wallet

Handles wallet management tasks, including encryption, unlocking/locking wallets, and managing wallet files.


SubstrateClient Class (Substrate .NET API)

The SubstrateClient class is a core component of the Substrate.NET API, designed to facilitate interaction with the Substrate blockchain in a .NET environment. It provides comprehensive functionalities for connecting to Substrate nodes and managing blockchain data.

Features:

  • Blockchain Connection: Methods for establishing and managing connections to Substrate nodes.
  • Data Handling: Capabilities to handle various blockchain-related data such as metadata, runtime versions, and genesis hash.
  • Modules Access: Access to blockchain modules like System, Chain, Payment, State, Author, and UnstableCalls.
  • Subscription and Storage: Functions for subscribing to blockchain events and retrieving storage data.
  • Asynchronous Operations: Support for asynchronous methods enhancing performance and efficiency.
  • Error Handling and Logging: Robust error handling mechanisms and logging capabilities for troubleshooting and monitoring.

Usage

Primarily used by developers for building .NET applications that require interaction with Substrate-based blockchains. It's versatile for various blockchain operations, from querying blockchain data to handling transactions. For in-detail usage, please refer to the Substrate .NET API WIki or take a look at the Unit Tests.

Modules

There are several modules, each tailored for specific functionalities and exposed via JSON-RPC, within the Substrate blockchain environment:

  • System: Manages system-level interactions and queries, such as retrieving blockchain properties and system health.
  • Chain: Handles chain-related functionalities, including accessing block data and chain history.
  • Payment: Focuses on payment-related operations, likely involving transaction fees and related queries.
  • State: Dedicated to managing and retrieving state information of the blockchain, such as storage data.
  • Author: Likely used for authoring and submitting extrinsics (transactions).
  • UnstableCalls: This module might include experimental or less stable features, providing advanced functionalities for developers who need them.

These modules collectively enable comprehensive interaction with the Substrate blockchain through the .NET environment. For a detailed exploration, refer to the Modules.


Wallet Class (Substrate.NET Wallet)

The Wallet class in the Substrate.NET Wallet library is designed for cryptocurrency wallet management in Substrate-based blockchain environments. It focuses on security, usability, and flexible management of wallet data.

Features:

  • Account Management: Handles account addresses and keys.
  • Encryption and Security: Deals with encrypted wallet data, ensuring security.
  • Wallet Unlocking/Locking: Provides functionalities to lock and unlock wallets.
  • Wallet File Management: Manages wallet files, including creation and storage checks.
  • Message Signing and Verification: Offers capabilities to sign and verify messages, crucial for transaction security.
  • Validation: Includes methods to validate wallet names and passwords.

Usage

Primarily used by developers for building .NET applications that require secure and efficient wallet management on Substrate-based blockchains.


Account Class (Substrate.NET API)

The Account class in the Substrate.NET API represents a fundamental element for handling blockchain accounts. It provides functionalities for creating and managing account keys and supports key types Ed25519 and Sr25519.

Key Features

  • KeyType Management: Handles different cryptographic key types, including Ed25519 and Sr25519.
  • Signing and Verification: Facilitates signing messages and verifying signatures, crucial for transaction security.
  • Private and Public Key Management: Manages account private and public keys.

General Architectural Principles

When creating applications with the Vara SDK for Unity, it's beneficial to follow these general architectural principles:

  • Segregation of Concerns: Modularize your project, ensuring each script or module has a specific purpose. This leads to a clearer structure, making your project easier to understand and maintain.
  • Keep it Simple and Stupid (KISS): Strive for simplicity in your design choices. Simpler solutions are often more efficient and easier to manage.

Adhering to these principles greatly enhances project organization and effectiveness, particularly when working with complex technologies like the Vara SDK for Unity.

Clone this wiki locally