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:
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:
Fetch- fetch a single object from Platform with proof verificationFetchMany- fetch multiple objects from Platform with proof verificationFetchUnproved- fetch a single object without proof verification (e.g., for node status queries)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:
Identifier- fetches an object by its identifierDocumentQuery- fetches documents based on search conditions; see query syntax documentation for more details.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:
PutIdentity- register a new identityPutContract- publish a data contractPutDocument- create or replace a documentTransferToIdentity- transfer credits between identitiesWithdrawFromIdentity- withdraw creditsTopUpIdentity- add credits to an identityPutVote- cast a masternode vote
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§
- Request
Settings - DAPI request settings.
Enums§
- Proof
Verifier Error - Errors
Constants§
- VERSION
- Version of the SDK