Skip to content

[Draft] w3sper SDK

Matteo Ferretti edited this page Sep 3, 2024 · 1 revision

w3sper SDK

The W3sper SDK (pronounced vesper, inspired by "the serene hour of dusk, just before nightfall, when the sky transitions to twilight", and also evocative of the word ‘whisper,’ reflecting Dusk's focus on privacy) is a comprehensive toolkit of modules designed to facilitate the development of applications that interact seamlessly with the Dusk Blockchain. The SDK will be available in two distinct versions: the Native SDK, and the Web SDK.

With the W3sper SDK, developers can effortlessly generate addresses and accounts, check balances, subscribe to network events and contract emissions, query blockchain data, create transactions, and much more.

Our wallets and blockchain explorer are powered by the W3sper SDK.

Modules

Below is an overview of the available modules and their functionalities. Each feature is neatly encapsulated within its respective module, enabling developers to import only the specific components they require. This modular approach also allows for easy expansion over time, such as integrating new modules or enhancing existing ones. However, certain functionalities may necessitate the combined use of multiple modules.

Native SDK Web SDK Module
Passphrase & Seed(s) Profile
Profiles (Account & Address) Profile
Profiles balances management Profile
Importing / Exporting Profiles Profile
Subscribe Live Events Events
Dispatching Events to Node / Contracts Events
Fetching previous contracts events Events
Ability to calculate the events' hash Events
Query Node for chain data Data (GraphQL)
Syncing with Contracts' state Profile / Events
Retreiving Profiles' Tx History Profile / Data
Signed Transactions creation Transaction
Importing call-data from remote DApps Transaction
Gas management Transaction
Dispatching Transactions Transaction / Events
Proof delegation Prover
Proof generation Prover

Architecture Overview

block-beta
  columns 3
  id1["execution-core"] :3
  block:group1:3
    columns 2
    id2{{"wallet-core"}}
    id3>"FFI"]
  end
  block:group2:3
    %% columns auto (default)
    columns 3
    Profile Events Prover Data Transactions
  end
Loading

The SDK is structured into three distinct layers: Execution Core, Wallet Core, and the High-Level API modules.

Execution Core

At the foundation of the SDK architecture lies the execution-core library. This library includes the protocol types used by the Dusk Network in its genesis contracts. It serves as the most fundamental API within the SDK, offering a low-level interface that can be directly integrated into contracts and applications. The Wallet Core encapsulates this library, providing a higher-level abstraction while retaining the essential functionalities of the Execution Core.

Wallet Core

The Wallet Core is the first layer of abstraction in the SDK, built on top of the Execution Core. It simplifies and customizes the use of the Execution Core, particularly for wallet management. This library is common to both the native and web versions of the SDK. It does not perform any I/O operations and is primarily utilized by the Profile component within the SDK, as well as for creating transactions. Key functionalities provided by the Wallet Core include:

  • Profiles (Account & Address)
  • Profiles balances management
  • Syncing with Contracts' state
  • Retreiving Profiles' Tx History
  • Signed Transactions creation
  • Dispatching Transactions

Note

The Wallet Core library incorporates a Foreign Function Interface (FFI) sub-layer, enabling the library to be utilized across multiple programming languages, including JavaScript through WebAssembly. It is important to highlight that the wallet-core library is entirely stateless and comprises only pure functions.

High-Level API

The topmost layer of the SDK is the High-Level API, which is exposed to the end-user. It consists of various components, including Prover, Profile, Events, Data, and Transactions. Unlike the lower layers, the implementation of the High-Level API diverges between the Web SDK and the Native SDK. The Native SDK is implemented in Rust, while the Web SDK is developed in JavaScript. This layer is responsible for handling I/O operations and network communication, making it the interface through which most interactions with the SDK occur.