Crate dash_sdk

Crate dash_sdk 

Source
Expand description

§Dash Platform Rust SDK

This is the official Rust SDK for the Dash Platform. Dash Platform is a Layer 2 cryptocurrency technology that builds upon the Dash layer 1 network. This SDK provides an abstraction layer to simplify usage of the Dash Platform along with data models based on the Dash Platform Protocol (DPP), query traits for reading data, and state transition traits for writing data.

§Dash Platform Protocol Data Model

SDK data model uses types defined in Dash Platform Protocol (DPP). The core types are:

  1. Identity
  2. DataContract
  3. Document

To define document search conditions, you can use DriveDocumentQuery and convert it to DocumentQuery with the From trait.

Basic DPP objects are re-exported in the platform module.

§Querying (Reading Data)

Data can be read from Platform using the following traits:

  1. Fetch - fetch a single object from Platform with proof verification
  2. FetchMany - fetch multiple objects from Platform with proof verification
  3. FetchUnproved - fetch a single object without proof verification (e.g., for node status queries)
  4. FetchCurrent - fetch current state for parameter-free queries (e.g., current epoch, total credits)

These traits return objects based on provided queries. Some example queries include:

  1. Identifier - fetches an object by its identifier
  2. DocumentQuery - fetches documents based on search conditions; see query syntax documentation for more details.
  3. DriveDocumentQuery - can be used to build more complex queries

§State Transitions (Writing Data)

Data is written to Platform by broadcasting state transitions. The SDK provides traits for common write operations:

For document operations, builder-based APIs are also available (see platform::documents::transitions).

§Testability

SDK operations can be mocked using Sdk::new_mock().

Examples can be found in tests/fetch/mock_fetch.rs and tests/fetch/mock_fetch_many.rs.

§Error handling

Errors of type Error are returned by the SDK. Note that missing objects (“not found”) are not treated as errors; Ok(None) is returned instead.

Mocking functions often panic instead of returning an error.

§Logging

This project uses the tracing crate for instrumentation and logging. The tracing ecosystem provides a powerful, flexible framework for adding structured, context-aware logs to your program.

To enable logging, you can use the tracing_subscriber crate which allows applications to customize how events are processed and recorded. An example can be found in tests/fetch/common.rs:setup_logs().

Re-exports§

pub use error::Error;
pub use sdk::Sdk;
pub use sdk::SdkBuilder;
pub use dapi_grpc;
pub use dpp;
pub use drive;
pub use grovedb_commitment_tree;
pub use rs_dapi_client as dapi_client;

Modules§

core
Dash Core SDK implementation.
error
Definitions of errors
mock
Mocking support for Dash SDK.
platform
Platform DAPI requests.
query_types
Object types that can be retrieved from proofs.
sdk
Sdk entrypoint to Dash Platform.
sync
Handle async calls from sync code.

Macros§

delegate_enum
Define enums that will wrap multiple requests/responses for one object.
delegate_from_proof_variant
Delegate the execution of a FromProof trait to an enum supporting multiple variants.
delegate_transport_request_variant
Delegate the execution of a transport request to the appropriate variant of an enum wrapper.

Structs§

RequestSettings
DAPI request settings.

Enums§

ProofVerifierError
Errors

Constants§

VERSION
Version of the SDK