Skip to main content

Sdk

Struct Sdk 

Source
pub struct Sdk {
    pub network: Network,
    /* private fields */
}
Expand description

Dash Platform SDK

This is the main entry point for interacting with Dash Platform. It can be initialized in two modes:

  • Normal: Connects to a remote Dash Platform node.
  • Mock: Uses a mock implementation of Dash Platform.

Recommended method of initialization is to use SdkBuilder. There are also some helper methods:

§Thread safety

Sdk is thread safe and can be shared between threads. It uses internal locking when needed.

It is also safe to clone the Sdk.

§Examples

See tests/ for examples of using the SDK.

Fields§

§network: Network

The network that the sdk is configured for (Dash (mainnet), Testnet, Devnet, Regtest)

Implementations§

Source§

impl Sdk

Source

pub async fn get_transaction( &self, txid: &str, ) -> Result<Option<FetchedCoreTransaction>, Error>

Fetch a Core transaction by its id via DAPI getTransaction.

txid is the transaction id as a hex string (big-endian display form). Returns Ok(Some(..)) with the decoded transaction plus its confirmation/lock metadata; Ok(None) when the node does not know the tx (empty response or gRPC NOT_FOUND) so the caller can retry with the id byte-reversed; and Err for a transient/transport failure that must not be masked by a doomed reversed-id retry.

Source

pub async fn get_transaction_placement( &self, txid: &str, settings: RequestSettings, ) -> Result<Option<CoreTransactionPlacement>, Error>

Fetch where a Core transaction was mined via DAPI getTransaction, including the block hash the node reports.

Same txid form and Ok(None) / Err contract as Sdk::get_transaction; settings override the SDK’s request settings for this call, so a caller on a deadline can bound it. The placement is unverified — see CoreTransactionPlacement.

Source

pub async fn get_block_by_hash( &self, hash: &BlockHash, settings: RequestSettings, ) -> Result<Option<Block>, Error>

Fetch a Core block by hash via DAPI getBlock.

Returns Ok(None) when the node does not serve the block (gRPC NOT_FOUND or an empty reply) and Err for any other failure, including bytes that do not decode as a block. The bytes are self-reported by the queried node: check block_hash() against a header chain you trust before relying on anything in the block.

Source

pub async fn start_instant_send_lock_stream( &self, from_block_hash: Vec<u8>, address: &Address, ) -> Result<Streaming<TransactionsWithProofsResponse>, Error>

Starts the stream to listen for instant send lock messages

Source

pub async fn wait_for_asset_lock_proof_for_transaction( &self, stream: Streaming<TransactionsWithProofsResponse>, transaction: &Transaction, time_out: Option<Duration>, ) -> Result<AssetLockProof, Error>

Waits for a response for the asset lock proof

Source§

impl Sdk

Source

pub async fn sync_address_balances<P: AddressProvider>( &self, provider: &mut P, config: Option<AddressSyncConfig>, last_sync_timestamp: Option<u64>, ) -> Result<AddressSyncResult<P::Tag, P::Address>, Error>

Synchronize address balances using privacy-preserving trunk/branch chunk queries with incremental block-based catch-up.

This method discovers address balances for addresses supplied by the provider, using an iterative query process that fetches chunks of the address tree rather than individual addresses. This provides privacy by making it unclear which specific addresses are being queried.

After the tree scan, incremental catch-up fetches balance changes from the checkpoint height to chain tip so the result is as fresh as possible.

On subsequent calls, pass AddressSyncResult::new_sync_timestamp as last_sync_timestamp so the function can decide whether a full tree rescan is needed or incremental-only catch-up suffices. The provider should implement AddressProvider::last_sync_height (returning the stored AddressSyncResult::new_sync_height) and AddressProvider::current_balances to supply state from the previous sync.

§Arguments
  • provider: An implementation of AddressProvider that supplies addresses and handles callbacks when addresses are found or proven absent.
  • config: Optional configuration; uses defaults if None.
  • last_sync_timestamp: Optional block time (Unix seconds) from the previous sync’s AddressSyncResult::new_sync_timestamp. Pass None to always perform a full tree scan.
§Returns
  • Ok(AddressSyncResult): Contains found addresses with balances/nonces, absent addresses, new_sync_height and new_sync_timestamp to store for the next call.
  • Err(Error): If the sync fails after exhausting retries.
§Example
ⓘ
use dash_sdk::{Sdk, platform::address_sync::{AddressProvider, AddressSyncConfig}};

// First sync — full tree scan + catch-up (no timestamp)
let result = sdk.sync_address_balances(&mut wallet, None, None).await?;
let saved_height = result.new_sync_height;       // → provider.last_sync_height()
let saved_timestamp = result.new_sync_timestamp;  // → last_sync_timestamp param

// Subsequent sync — incremental only if within threshold
let result = sdk.sync_address_balances(&mut wallet, None, Some(saved_timestamp)).await?;
Source§

impl Sdk

Source

pub async fn create_contact_request<F, Fut, G, Gut, H, Hut>( &self, input: ContactRequestInput, ecdh_provider: EcdhProvider<F, Fut, G, Gut>, get_extended_public_key: H, ) -> Result<ContactRequestResult, Error>
where F: FnOnce(&IdentityPublicKey, u32) -> Fut, Fut: Future<Output = Result<SecretKey, Error>>, G: FnOnce(&PublicKey) -> Gut, Gut: Future<Output = Result<[u8; 32], Error>>, H: FnOnce(u32) -> Hut, Hut: Future<Output = Result<Vec<u8>, Error>>,

Create a contact request document

This creates a local contact request document according to DIP-15 specification. The document is not yet submitted to the platform. This method automatically handles ECDH key derivation and encryption of the extended public key and account label.

§Arguments
  • input - The contact request input containing sender/recipient information and unencrypted data
  • ecdh_provider - Provider for ECDH key exchange (client-side or SDK-side)
  • get_extended_public_key - Async function to retrieve the extended public key to share with recipient
    • Parameters: (account_reference: u32)
    • Returns: The unencrypted extended public key bytes — the 69-byte DIP-15 compact form (parentFingerprint(4) ‖ chainCode(32) ‖ pubKey(33)), NOT a 78/107-byte BIP32/DIP-14 serialization. A non-69-byte return is rejected before encryption.
§Returns

Returns a ContactRequestResult containing the created document

§Errors

Returns an error if:

  • The DashPay contract cannot be fetched
  • The contactRequest document type is not found
  • The sender or recipient doesn’t have the required encryption keys
  • ECDH encryption fails
  • The shared secret, private key, or extended public key cannot be retrieved
Source

pub async fn send_contact_request<S: Signer<IdentityPublicKey>, F, Fut, G, Gut, H, Hut>( &self, input: SendContactRequestInput<S>, ecdh_provider: EcdhProvider<F, Fut, G, Gut>, get_extended_public_key: H, ) -> Result<SendContactRequestResult, Error>
where F: FnOnce(&IdentityPublicKey, u32) -> Fut, Fut: Future<Output = Result<SecretKey, Error>>, G: FnOnce(&PublicKey) -> Gut, Gut: Future<Output = Result<[u8; 32], Error>>, H: FnOnce(u32) -> Hut, Hut: Future<Output = Result<Vec<u8>, Error>>,

Send a contact request to the platform

This creates a contact request document with automatic ECDH encryption and submits it to the platform as a state transition.

§Arguments
  • input - The send contact request input containing document data, key, and signer
  • ecdh_provider - Provider for ECDH key exchange (client-side or SDK-side)
  • get_extended_public_key - Async function to retrieve the extended public key to share with recipient
    • Parameters: (account_reference: u32)
    • Returns: The unencrypted extended public key bytes — the 69-byte DIP-15 compact form (parentFingerprint(4) ‖ chainCode(32) ‖ pubKey(33)), NOT a 78/107-byte BIP32/DIP-14 serialization.
§Returns

Returns a SendContactRequestResult containing the submitted document

§Errors

Returns an error if:

  • Document creation fails (including ECDH encryption)
  • State transition submission fails
Source§

impl Sdk

Source

pub async fn fetch_sent_contact_requests( &self, identity_id: Identifier, after_created_at: Option<u64>, ) -> Result<ContactRequestDocuments, Error>

Fetch contact requests sent by identity_id ($ownerId ==), newer than after_created_at if given, fully paginated.

Source

pub async fn fetch_received_contact_requests( &self, identity_id: Identifier, after_created_at: Option<u64>, ) -> Result<ContactRequestDocuments, Error>

Fetch contact requests received by identity_id (toUserId ==), newer than after_created_at if given, fully paginated.

Source

pub async fn fetch_all_contact_requests_for_identity( &self, identity: &Identity, after_created_at: Option<u64>, ) -> Result<(ContactRequestDocuments, ContactRequestDocuments), Error>

Fetch both sent and received contact requests for an identity, each newer than after_created_at if given.

Source§

impl Sdk

Source

pub async fn invitation_prospective_identity_id( &self, invitation: &ParsedInvitation, ) -> Result<Identifier, InvitationError>

The identity id this invitation WOULD create, without claiming it.

Platform derives a created identity’s id from the asset-lock outpoint, so the id is knowable before the claim. The claim is otherwise the only way to learn a voucher is spent, which is why a used invitation surfaces as a raw “asset lock … already completely used” after the invitee has picked a username and entered their PIN.

§Detects claims, not consumption — the signal is ONE-WAY

An identity existing under the returned id means the voucher was definitely claimed. Its absence does not mean the voucher is usable.

The lock can also be consumed by IdentityTopUp — an inviter reclaiming the voucher into one of its existing identities — which credits an EXISTING identity rather than creating the derived one. Afterwards no identity exists at this id, yet a claim still fails deterministically because the asset-lock output is already spent.

Platform exposes no client query for spent asset locks (drive tracks them under SpentAssetLockTransactions, but no DAPI endpoint surfaces it), so consumption cannot be checked from here. Callers must therefore treat this as a fast-fail for the common case only: reject the invitation when an identity exists, and otherwise proceed WITHOUT concluding the voucher is usable. It narrows when the late failure happens; it does not remove it.

Costs one funding-tx fetch: the outpoint is not in the link (the credit output is selected by pk↔script match, not by index), so the tx has to be refetched exactly as the claim does. Same wrong-network fail-fast as Sdk::claim_invitation, so a testnet link on mainnet reports the network mismatch rather than a confusing fetch miss.

Source

pub async fn invitation_claim_status( &self, invitation: &ParsedInvitation, ) -> Result<InvitationClaimStatus, InvitationError>

What an invitation is worth and whether it was already claimed — the invitee’s pre-claim check, one network round trip before any username is picked.

The amount is the tier signal: the link does not say whether it funds a contested or a non-contested username, the value of the voucher’s credit output does (the inviter chose it). It is read from the same refetched funding transaction the claim uses, so it is exactly what the claim would spend.

already_claimed carries the one-way caveat of Sdk::invitation_prospective_identity_id: true is definitive, false does not prove the voucher is unspent (a reclaim top-up consumes it without creating the derived identity).

It describes the funding transaction rather than requiring a buildable proof: a ChainLock-only link whose funding tx is not chain-locked yet reports is_instant == false, is_chain_locked == false and its amount instead of failing (the claim of such a link waits for the ChainLock). A failed identity lookup still fails the whole call.

Costs one funding-tx fetch (with the claim’s bounded propagation retry) and one identity fetch. Same wrong-network fail-fast as the claim.

Source

pub async fn claim_invitation<S>( &self, invitation: ParsedInvitation, keys_map: BTreeMap<KeyID, IdentityPublicKey>, identity_signer: &S, settings: Option<PutSettings>, ) -> Result<Identity, InvitationError>
where S: Signer<IdentityPublicKey> + Send + Sync,

Claim a DashPay invitation: register a NEW identity for the invitee, funded by the imported voucher.

The link carries only the voucher key + funding txid (+ optional islock), not the funding proof — so this refetches the funding transaction from Core and reconstructs the asset-lock proof, mirroring the legacy Android claim (TopUpRepository.obtainAssetLockTransaction):

  1. Fetch the tx by funding_txid; retry byte-reversed on a miss (old iOS links are little-endian).
  2. Fail-fast that the fetched tx is really the funding tx, and (if an islock is present) that the islock locks it.
  3. Select the funded credit output by pk↔script match (not index 0).
  4. Build an InstantAssetLockProof when an islock is present (the fast path), else a ChainAssetLockProof once the funding tx is chain-locked.

The IS proof is the fast path only: a voucher islock is signed at creation, so by the time the invitee claims (minutes-to-hours later, and on testnet possibly across a quorum rotation) Drive may reject the islock as stale with InvalidInstantAssetLockProofSignatureError — its own message asks to “try chain asset lock proof instead”. An islock proof over a funding tx with many inputs can also make the claim larger than max_state_transition_size. When the funding tx is already chain-locked (the usual case by claim time), this resubmits a ChainAssetLockProof over the SAME credit output — for the size case only if the claim fits with it. If the tx is not yet chain-locked no fallback is possible and the claim returns InvitationError::NotChainLocked as a retry signal.

The invitee’s own identity keys (keys_map) are signed by identity_signer; the asset-lock’s outer state-transition signature is produced from the imported voucher key (invitation.voucher_key) via the SDK’s in-process raw-key path. The invitee owns neither the lock’s inputs nor its tracking. keys_map[0] must be a MASTER-level AUTHENTICATION key.

A claim repeated after an earlier one landed is refused by Platform because its outpoint is consumed; the identity at the prospective id is returned when it carries exactly the submitted keys.

The caller records the returned identity in its own wallet; nothing is persisted here. The contact-bootstrap is a separate step: on success the caller may send the inviter a contact request.

Source§

impl Sdk

Source

pub async fn get_profiles( &self, dashpay_contract: &Arc<DataContract>, owner_ids: &[Identifier], ) -> Result<BTreeMap<Identifier, Document>, Error>

Fetch the profile documents of owner_ids (unique), keyed by owner id, in queries of at most 100 owners each. An owner without a profile is missing from the result. A duplicated owner is rejected with Error::Generic before any query.

dashpay_contract must be the DashPay system data contract.

Source

pub async fn create_profile<S: Signer<IdentityPublicKey>>( &self, dashpay_contract: &Arc<DataContract>, owner_id: Identifier, fields: ProfileFields, signing_key: &IdentityPublicKey, signer: &S, ) -> Result<Document, Error>

Create the profile document of owner_id from fields.

signing_key must be a HIGH or CRITICAL authentication key of the owner. Returns the document as confirmed by Platform.

Source

pub async fn create_profile_with_owner_balance_and_metadata<S: Signer<IdentityPublicKey>>( &self, dashpay_contract: &Arc<DataContract>, owner_id: Identifier, fields: ProfileFields, signing_key: &IdentityPublicKey, signer: &S, ) -> Result<(Document, Option<Credits>, ResponseMetadata), Error>

Self::create_profile that also returns the owner’s credit balance after the write, when the proof carries it (from protocol version 14), and the proof’s verified response metadata, whose height is the block the balance is a snapshot at.

Source

pub async fn update_profile<S: Signer<IdentityPublicKey>>( &self, dashpay_contract: &Arc<DataContract>, owner_id: Identifier, fields: ProfileFields, signing_key: &IdentityPublicKey, signer: &S, ) -> Result<Document, Error>

Update the existing profile document of owner_id: read it, overlay the fields that are set so a partial update keeps the other fields, increment the revision and replace it.

The two avatar hashes are set together, and a changed avatar_url comes with both hashes; otherwise the call fails before anything is signed. An unchanged avatar_url may be sent without hashes, which keeps the existing ones.

signing_key must be a HIGH or CRITICAL authentication key of the owner. Returns the merged document as confirmed by Platform. Fails if the owner has no profile.

Source

pub async fn update_profile_with_owner_balance_and_metadata<S: Signer<IdentityPublicKey>>( &self, dashpay_contract: &Arc<DataContract>, owner_id: Identifier, fields: ProfileFields, signing_key: &IdentityPublicKey, signer: &S, ) -> Result<(Document, Option<Credits>, ResponseMetadata), Error>

Self::update_profile that also returns the owner’s credit balance after the write, when the proof carries it (from protocol version 14), and the proof’s verified response metadata, whose height is the block the balance is a snapshot at.

Source§

impl Sdk

Source

pub async fn contest_fund_to_join( &self, document_type: DocumentTypeRef<'_>, document: &Document, ) -> Result<Option<Credits>, Error>

The fund a contested create of document pays to join its contest now, or None when the document joins no contest: the contest’s fund, doubled once the contest holds 250 contenders and again for every 50 more (protocol version 14; before it the fund never doubles).

The contenders are counted with proved contested resource vote state queries of up to 100 contenders each, so a contest of n contenders costs n / 100 + 1 of them. The fund is priced at the protocol version known once they are read, which the first response of an SDK that auto-detects the version brings.

Source

pub async fn prefunded_voting_balance_to_join( &self, document_type: DocumentTypeRef<'_>, document: &Document, ) -> Result<Option<(String, Credits)>, Error>

The prefunded voting balance a create of document states to join its contest now: the name of the contested index the document falls under and Self::contest_fund_to_join, or None when the document joins no contest. It is what a create transition built by hand carries, the pair DocumentCreateTransition keeps as prefunded_voting_balance.

Source§

impl Sdk

Source

pub async fn document_create<S: Signer<IdentityPublicKey>>( &self, create_document_transition_builder: DocumentCreateTransitionBuilder, signing_key: &IdentityPublicKey, signer: &S, ) -> Result<DocumentCreateResult, Error>

Creates a new document on the platform.

This method broadcasts a document creation transition to add a new document to the specified data contract. The result contains the created document. For an indexOnly document type the proof shows the document’s entry at the proof’s block, not that this create wrote it: no stronger proof exists for such a document.

§Arguments
  • create_document_transition_builder - Builder containing document creation parameters
  • signing_key - The identity public key for signing the transition
  • signer - Implementation of the Signer trait for cryptographic signing
§Returns

Returns a Result containing a DocumentCreateResult on success, or an Error on failure.

§Errors

This function will return an error if:

  • The transition signing fails
  • Broadcasting the transition fails
  • The proof verification returns an unexpected result type
  • Document validation fails
Source§

impl Sdk

Source

pub async fn document_delete<S: Signer<IdentityPublicKey>>( &self, delete_document_transition_builder: DocumentDeleteTransitionBuilder, signing_key: &IdentityPublicKey, signer: &S, ) -> Result<DocumentDeleteResult, Error>

Deletes an existing document from the platform.

This method broadcasts a document deletion transition to permanently remove a document from the platform. The result confirms the deletion. For an indexOnly document type the proof shows the document’s entry gone at the proof’s block, not that this delete removed it: no stronger proof exists for such a document.

§Arguments
  • delete_document_transition_builder - Builder containing document deletion parameters
  • signing_key - The identity public key for signing the transition
  • signer - Implementation of the Signer trait for cryptographic signing
§Returns

Returns a Result containing a DocumentDeleteResult on success, or an Error on failure.

§Errors

This function will return an error if:

  • The transition signing fails
  • Broadcasting the transition fails
  • The proof verification returns an unexpected result type
  • Document not found or already deleted
  • Insufficient permissions to delete the document
Source§

impl Sdk

Source

pub async fn document_purchase<S: Signer<IdentityPublicKey>>( &self, purchase_document_transition_builder: DocumentPurchaseTransitionBuilder, signing_key: &IdentityPublicKey, signer: &S, ) -> Result<DocumentPurchaseResult, Error>

Purchases a document from its current owner.

This method broadcasts a document purchase transition to buy a document at its set price and transfer ownership to the purchaser. The result contains the purchased document with updated ownership.

§Arguments
  • purchase_document_transition_builder - Builder containing purchase parameters
  • signing_key - The identity public key for signing the transition
  • signer - Implementation of the Signer trait for cryptographic signing
§Returns

Returns a Result containing a DocumentPurchaseResult on success, or an Error on failure.

§Errors

This function will return an error if:

  • The transition signing fails
  • Broadcasting the transition fails
  • The proof verification returns an unexpected result type
  • Document not found or not for sale
  • Insufficient funds to complete the purchase
  • Price mismatch (document price changed)
  • Invalid purchaser identity
Source§

impl Sdk

Source

pub async fn document_replace<S: Signer<IdentityPublicKey>>( &self, replace_document_transition_builder: DocumentReplaceTransitionBuilder, signing_key: &IdentityPublicKey, signer: &S, ) -> Result<DocumentReplaceResult, Error>

Replaces an existing document on the platform.

This method broadcasts a document replacement transition to update an existing document with new data. The result contains the updated document.

§Arguments
  • replace_document_transition_builder - Builder containing document replacement parameters
  • signing_key - The identity public key for signing the transition
  • signer - Implementation of the Signer trait for cryptographic signing
§Returns

Returns a Result containing a DocumentReplaceResult on success, or an Error on failure.

§Errors

This function will return an error if:

  • The transition signing fails
  • Broadcasting the transition fails
  • The proof verification returns an unexpected result type
  • Document validation fails
  • Document not found or revision mismatch
Source§

impl Sdk

Source

pub async fn document_set_price<S: Signer<IdentityPublicKey>>( &self, set_price_document_transition_builder: DocumentSetPriceTransitionBuilder, signing_key: &IdentityPublicKey, signer: &S, ) -> Result<DocumentSetPriceResult, Error>

Sets the price for a document on the platform.

This method broadcasts a document price update transition to set or change the price of an existing document. The result contains the updated document.

§Arguments
  • set_price_document_transition_builder - Builder containing price update parameters
  • signing_key - The identity public key for signing the transition
  • signer - Implementation of the Signer trait for cryptographic signing
§Returns

Returns a Result containing a DocumentSetPriceResult on success, or an Error on failure.

§Errors

This function will return an error if:

  • The transition signing fails
  • Broadcasting the transition fails
  • The proof verification returns an unexpected result type
  • Document not found
  • Insufficient permissions to set price
  • Invalid price value
Source§

impl Sdk

Source

pub async fn document_transfer<S: Signer<IdentityPublicKey>>( &self, transfer_document_transition_builder: DocumentTransferTransitionBuilder, signing_key: &IdentityPublicKey, signer: &S, ) -> Result<DocumentTransferResult, Error>

Transfers ownership of a document to another identity.

This method broadcasts a document transfer transition to change the ownership of an existing document to a new identity. The result contains the transferred document.

§Arguments
  • transfer_document_transition_builder - Builder containing transfer parameters
  • signing_key - The identity public key for signing the transition
  • signer - Implementation of the Signer trait for cryptographic signing
§Returns

Returns a Result containing a DocumentTransferResult on success, or an Error on failure.

§Errors

This function will return an error if:

  • The transition signing fails
  • Broadcasting the transition fails
  • The proof verification returns an unexpected result type
  • Document not found
  • Insufficient permissions to transfer the document
  • Invalid recipient identity
Source§

impl Sdk

Source

pub async fn get_contested_dpns_normalized_usernames( &self, limit: Option<u32>, start_after: Option<String>, ) -> Result<Vec<String>, Error>

Get all contested DPNS usernames

Reads the names in ascending order, in pages of up to 100 (the most Drive answers to one query), until limit names are read or none are left.

§Arguments
  • limit - Maximum number of results to return; None returns every name
  • start_after - Optional name to start after (for pagination)
§Returns

Returns a list of contested DPNS usernames

Source

pub async fn get_contested_dpns_vote_state( &self, label: &str, limit: Option<u32>, ) -> Result<Contenders, Error>

Get the vote state for a contested DPNS username

§Arguments
  • label - The username label to check (e.g., “alice”)
  • limit - Maximum number of contenders to return
§Returns

Returns the contenders and their vote counts for the username

Source

pub async fn get_contested_dpns_voters_for_identity( &self, label: &str, contestant_id: Identifier, limit: Option<u32>, ) -> Result<(), Error>

Get voters who voted for a specific identity for a contested DPNS username

§Arguments
  • label - The username label (e.g., “alice”)
  • contestant_id - The identity ID of the contestant
  • limit - Maximum number of voters to return
§Returns

Returns the list of masternode voters who voted for this contestant

Source

pub async fn get_contested_dpns_identity_votes( &self, identity_id: Identifier, limit: Option<u32>, offset: Option<u16>, ) -> Result<Vec<ContestedDpnsUsername>, Error>

Get all contested DPNS usernames that an identity has voted on

§Arguments
  • identity_id - The identity ID (typically a masternode ProTxHash)
  • limit - Maximum number of votes to return
  • offset - Offset for pagination
§Returns

Returns the list of contested DPNS usernames this identity has voted on

Source

pub async fn get_contested_dpns_usernames_by_identity( &self, identity_id: Identifier, limit: Option<u32>, ) -> Result<Vec<ContestedDpnsUsername>, Error>

Get all contested DPNS usernames where an identity is a contender

§Arguments
  • identity_id - The identity ID to search for
  • limit - Maximum number of results to return
§Returns

Returns the list of contested DPNS usernames where this identity is competing

Source

pub async fn get_contested_non_resolved_usernames( &self, limit: Option<u32>, ) -> Result<BTreeMap<String, ContestInfo>, Error>

Get contested usernames that are not yet resolved

This method fetches all currently contested DPNS usernames that haven’t been resolved yet. It gets current contests and returns the contenders and end time for each unresolved name.

§Arguments
  • limit - Maximum number of results to return
§Returns

Returns a map of contested but unresolved DPNS usernames to their contest info (contenders and end time)

Source

pub async fn get_non_resolved_dpns_contests_for_identity( &self, identity_id: Identifier, limit: Option<u32>, ) -> Result<BTreeMap<String, ContestInfo>, Error>

Get non-resolved DPNS contests for a specific identity

This method fetches all currently contested DPNS usernames that haven’t been resolved yet and filters them to only include contests where the specified identity is a contender.

§Arguments
  • identity_id - The identity ID to filter contests for
  • limit - Maximum number of results to return
§Returns

Returns a map of contested but unresolved DPNS usernames (where the identity is a contender) to their contenders

Source

pub async fn get_current_dpns_contests( &self, start_time: Option<TimestampMillis>, end_time: Option<TimestampMillis>, limit: Option<u16>, ) -> Result<BTreeMap<String, TimestampMillis>, Error>

Get current DPNS contests (active vote polls)

This method fetches all currently active DPNS username contests by querying vote polls by their end date. It automatically paginates through all results if there are more than the limit.

§Arguments
  • start_time - Optional start time to filter contests (in milliseconds)
  • end_time - Optional end time to filter contests (in milliseconds)
  • limit - Maximum number of results per query (defaults to 100)
§Returns

Returns a map of contested DPNS names to their end timestamps

Source§

impl Sdk

Source

pub async fn get_dpns_usernames_by_identity( &self, identity_id: Identifier, limit: Option<u32>, ) -> Result<Vec<DpnsUsername>, Error>

Get DPNS usernames owned by a specific identity

This searches for domains where the identity is listed in records.identity. Note: This does not search for domains owned by the identity (no index on $ownerId)

§Arguments
  • identity_id - The identity ID to search for
  • limit - Maximum number of results to return (default: 10)
§Returns

Returns a list of DPNS usernames associated with the identity

Source

pub async fn get_all_dpns_usernames_by_identity( &self, identity_id: Identifier, page_limit: u32, max_pages: usize, ) -> Result<(Vec<DpnsUsername>, bool), Error>

Get every DPNS username associated with identity_id, paging through the records.identity index page_limit documents at a time.

Returns the usernames and whether the set is known to be complete: true once a page comes back shorter than page_limit, false when the end was not provably reached (the caller must then treat the result as a lower bound, not the owned set). Documents that do not parse as DPNS domains are skipped, as in Self::get_dpns_usernames_by_identity.

§When true can be trusted

Continuing a page relies on startAfter inside the records.identity equality bucket, which only the query lowering introduced with protocol version 14 (non_primary_key_path_query: 1) serves. The earlier lowering drops the rest of the bucket after any cursor, so a second page would come back empty and read as the end. On such a platform version (the one the SDK runs at once the first page has answered) the loop reads only the first page: true then means the identity has fewer than page_limit names, and a full first page returns false. Otherwise false means max_pages full pages were read without reaching the end.

Source

pub async fn check_dpns_name_availability( &self, label: &str, ) -> Result<bool, Error>

Check if a DPNS username is available

§Arguments
  • label - The username label to check (e.g., “alice”)
§Returns

Returns true if the username is available, false if it’s taken

Source

pub async fn resolve_dpns_name_to_identity( &self, name: &str, ) -> Result<Option<Identifier>, Error>

Resolve a DPNS name to an identity ID

§Arguments
  • name - The full domain name (e.g., “alice.dash”) or just the label (e.g., “alice”)
§Returns

Returns the identity ID associated with the domain, or None if not found

Source

pub async fn search_dpns_names( &self, prefix: &str, limit: Option<u32>, ) -> Result<Vec<DpnsUsername>, Error>

Search for DPNS names that start with a given prefix

§Arguments
  • prefix - The prefix to search for (e.g., “ali” to find “alice”, “alicia”, etc.)
  • limit - Maximum number of results to return (default: 10)
§Returns

Returns a list of DPNS usernames that match the prefix

Source§

impl Sdk

Source

pub async fn register_dpns_name<S: Signer<IdentityPublicKey>>( &self, input: RegisterDpnsNameInput<S>, ) -> Result<RegisterDpnsNameResult, Error>

Register a DPNS username in a single operation

This method handles both the preorder and domain registration steps automatically. It generates the necessary entropy, creates both documents, and submits them in order.

§Arguments
  • input - The registration input containing label, identity, public key, and signer
§Returns

Returns a RegisterDpnsNameResult containing both created documents and the full domain name

§Errors

Returns an error if:

  • The DPNS contract cannot be fetched
  • Document types are not found in the contract
  • Document creation or submission fails
Source

pub async fn register_dpns_name_with_owner_balance_and_metadata<S: Signer<IdentityPublicKey>>( &self, input: RegisterDpnsNameInput<S>, ) -> Result<(RegisterDpnsNameResult, Option<Credits>, ResponseMetadata), Error>

Register a DPNS username like Sdk::register_dpns_name, and also return what the domain document’s proof carries next to the document: the credit balance of the registering identity after the registration (None for a proof made before protocol version 14) and the verified metadata of that response, whose height is the block the balance is a snapshot at.

The domain is the registration’s last write, so its balance already includes what the preorder cost.

Source

pub async fn is_dpns_name_available(&self, name: &str) -> Result<bool, Error>

Check if a DPNS name is available

§Arguments
  • name - The username label (e.g., “alice”) or full DPNS name (e.g., “alice.dash”). The .dash suffix is matched case-insensitively and stripped before normalization, mirroring Sdk::resolve_dpns_name.
§Returns

Returns true if the name is available, false if it’s taken

Source

pub async fn resolve_dpns_name( &self, name: &str, ) -> Result<Option<Identifier>, Error>

Resolve a DPNS name to an identity ID

§Arguments
  • name - The full domain name (e.g., “alice.dash”) or just the label (e.g., “alice”)
§Returns

Returns the identity ID associated with the domain, or None if not found

Source§

impl Sdk

Source

pub async fn fetch_seated_charter( &self, target_contract_id: Identifier, ) -> Result<Option<SeatedCharter>, Error>

The seated charter of target_contract_id: the electedCharter whose targetContractId is it, None when the contract has none (no contest awarded yet, or no elected moderation at all).

Source

pub async fn fetch_submitted_charter( &self, submitted_charter_id: Identifier, ) -> Result<Option<Document>, Error>

The submittedCharter (a proposal) with id submitted_charter_id, None when there is none.

Source

pub async fn fetch_elected_charter( &self, elected_charter_id: Identifier, ) -> Result<Option<SeatedCharter>, Error>

The electedCharter with id elected_charter_id, None when there is none. A stored elected charter is always a seated one.

Source

pub async fn fetch_moderation_team( &self, target_contract_id: Identifier, ) -> Result<Option<ModerationTeam>, Error>

The team that moderates target_contract_id: the seated charter’s leader plus its elected members and the members the leader added, less those the leader removed. None when the contract has no seated charter.

Source

pub async fn fetch_submitted_charters( &self, target_contract_id: Identifier, page: CharterDocumentsPage, ) -> Result<Documents, Error>

One page of the proposals (submittedCharter documents) for target_contract_id, in filing order. CharterDocumentsPage::after gives the next page.

Source

pub async fn fetch_join_requests( &self, submitted_charter_id: Identifier, page: CharterDocumentsPage, ) -> Result<Documents, Error>

One page of the join requests for the proposal submitted_charter_id, in the order of their owners’ ids. CharterDocumentsPage::after gives the next page.

Source

pub async fn fetch_pending_resignation_requests( &self, elected_charter_id: Identifier, ) -> Result<Vec<Document>, Error>

The resignation requests for the charter elected_charter_id the leader has not acted on: those whose writer is still on the team (the leader takes an added member off by deleting its addedModerator, and an elected one with a removedModerator). A withdrawn request is deleted, so it is not among them either. Empty when there is no such charter.

Source§

impl Sdk

Source

pub async fn build_join_request( &self, input: JoinRequestInput, ) -> Result<ModerationCharterRequest, Error>

Builds a join request for the proposal input.submitted_charter_id: fetches the proposal and its leader, and encrypts the message with the keys the schema demands (see build_join_request_document). The result is put like any document create.

Source

pub async fn build_resignation_request( &self, input: ResignationRequestInput, ) -> Result<ModerationCharterRequest, Error>

Builds a resignation request from the seated charter input.elected_charter_id: fetches the charter and its leader, and encrypts the message with the keys the schema demands (see build_resignation_request_document). The result is put like any document create; deleting the document withdraws the request.

Source§

impl Sdk

Source

pub async fn fetch_moderation_charters_contract( &self, ) -> Result<Arc<DataContract>, Error>

The moderation charters system contract: from the context provider when it holds it, fetched otherwise.

The contract exists from protocol version 14. An unpinned SDK starts mainnet and testnet at 13 and only learns a newer version from a verified response, and the contract’s schema does not parse at 13, so below 14 the SDK first learns the network’s version; a network still below 14 has no such contract, which is an error.

Source§

impl Sdk

Source

pub async fn fetch_system_data_contract( &self, contract_id: Identifier, ) -> Result<Option<Arc<DataContract>>, Error>

The system data contract contract_id, from the context provider when it holds it at the SDK’s protocol version, fetched and proved otherwise. None when the network has no such contract.

Source§

impl Sdk

Source

pub async fn token_burn<S: Signer<IdentityPublicKey>>( &self, burn_tokens_transition_builder: TokenBurnTransitionBuilder, signing_key: &IdentityPublicKey, signer: &S, ) -> Result<BurnResult, Error>

Burns tokens to permanently remove them from circulation.

This method broadcasts a burn transition to destroy a specified amount of tokens. The result varies based on token configuration:

  • Standard tokens return the owner’s remaining balance
  • Tokens with history tracking return documents
  • Group-managed tokens include group power and action status
§Arguments
  • burn_tokens_transition_builder - Builder containing burn parameters including amount
  • signing_key - The identity public key for signing the transition
  • signer - Implementation of the Signer trait for cryptographic signing
§Returns

Returns a Result containing a BurnResult on success, or an Error on failure.

§Errors

This function will return an error if:

  • The transition signing fails
  • Broadcasting the transition fails
  • The proof verification returns an unexpected result type
  • Insufficient token balance for burning
Source§

impl Sdk

Source

pub async fn token_claim<S: Signer<IdentityPublicKey>>( &self, claim_tokens_transition_builder: TokenClaimTransitionBuilder, signing_key: &IdentityPublicKey, signer: &S, ) -> Result<ClaimResult, Error>

Claims tokens for a specific identity.

This method broadcasts a claim transition to acquire ownership of tokens that have been allocated or made available for claiming. The result includes a document that records the claim details.

§Arguments
  • claim_tokens_transition_builder - Builder containing claim parameters
  • signing_key - The identity public key for signing the transition
  • signer - Implementation of the Signer trait for cryptographic signing
§Returns

Returns a Result containing a ClaimResult on success, or an Error on failure.

§Errors

This function will return an error if:

  • The transition signing fails
  • Broadcasting the transition fails
  • The proof verification returns an unexpected result type
  • A group action result is missing the expected document
Source§

impl Sdk

Source

pub async fn token_update_contract_token_configuration<S: Signer<IdentityPublicKey>>( &self, config_update_transition_builder: TokenConfigUpdateTransitionBuilder, signing_key: &IdentityPublicKey, signer: &S, ) -> Result<ConfigUpdateResult, Error>

Updates the configuration of a token contract.

This method broadcasts a configuration update transition to modify token settings such as minting rules, transfer restrictions, or other contract parameters. The result includes a document with the updated configuration details, except for a group action that is still active.

§Arguments
  • config_update_transition_builder - Builder containing configuration update parameters
  • signing_key - The identity public key for signing the transition
  • signer - Implementation of the Signer trait for cryptographic signing
§Returns

Returns a Result containing a ConfigUpdateResult on success, or an Error on failure.

§Errors

This function will return an error if:

  • The transition signing fails
  • Broadcasting the transition fails
  • The proof verification returns an unexpected result type
Source§

impl Sdk

Source

pub async fn token_destroy_frozen_funds<S: Signer<IdentityPublicKey>>( &self, destroy_frozen_funds_transition_builder: TokenDestroyFrozenFundsTransitionBuilder, signing_key: &IdentityPublicKey, signer: &S, ) -> Result<DestroyFrozenFundsResult, Error>

Destroys frozen tokens permanently.

This method broadcasts a destroy frozen funds transition to permanently remove frozen tokens from circulation. This operation always maintains a historical record of the destruction.

§Arguments
  • destroy_frozen_funds_transition_builder - Builder containing destruction parameters
  • signing_key - The identity public key for signing the transition
  • signer - Implementation of the Signer trait for cryptographic signing
§Returns

Returns a Result containing a DestroyFrozenFundsResult on success, or an Error on failure.

§Errors

This function will return an error if:

  • The transition signing fails
  • Broadcasting the transition fails
  • The proof verification returns an unexpected result type
Source§

impl Sdk

Source

pub async fn token_purchase<S: Signer<IdentityPublicKey>>( &self, purchase_tokens_transition_builder: TokenDirectPurchaseTransitionBuilder, signing_key: &IdentityPublicKey, signer: &S, ) -> Result<DirectPurchaseResult, Error>

Purchases tokens directly at the configured price.

This method broadcasts a direct purchase transition to buy tokens at the price set by the token owner. The purchase uses platform credits as payment. The result varies based on token configuration:

  • Standard tokens return the purchaser’s new balance
  • Tokens with history tracking return documents
  • Group-managed tokens include group power information
§Arguments
  • purchase_tokens_transition_builder - Builder containing purchase parameters including amount
  • signing_key - The identity public key for signing the transition
  • signer - Implementation of the Signer trait for cryptographic signing
§Returns

Returns a Result containing a DirectPurchaseResult on success, or an Error on failure.

§Errors

This function will return an error if:

  • The transition signing fails
  • Broadcasting the transition fails
  • The proof verification returns an unexpected result type
  • Insufficient credits for the purchase
Source§

impl Sdk

Source

pub async fn token_emergency_action<S: Signer<IdentityPublicKey>>( &self, emergency_action_transition_builder: TokenEmergencyActionTransitionBuilder, signing_key: &IdentityPublicKey, signer: &S, ) -> Result<EmergencyActionResult, Error>

Executes an emergency action on a token contract.

This method broadcasts an emergency action transition for critical token management operations that require group authorization. Emergency actions are typically used for scenarios like halting trading, recovering from critical bugs, or other urgent interventions.

§Arguments
  • emergency_action_transition_builder - Builder containing emergency action parameters
  • signing_key - The identity public key for signing the transition
  • signer - Implementation of the Signer trait for cryptographic signing
§Returns

Returns a Result containing an EmergencyActionResult on success, or an Error on failure.

§Errors

This function will return an error if:

  • The transition signing fails
  • Broadcasting the transition fails
  • The proof verification returns an unexpected result type
  • The group authorization is insufficient
Source§

impl Sdk

Source

pub async fn token_freeze<S: Signer<IdentityPublicKey>>( &self, freeze_tokens_transition_builder: TokenFreezeTransitionBuilder, signing_key: &IdentityPublicKey, signer: &S, ) -> Result<FreezeResult, Error>

Freezes tokens for a specific identity.

This method broadcasts a freeze transition to temporarily lock tokens, preventing their transfer until they are unfrozen. The result varies based on token configuration:

  • Standard tokens return identity info
  • Tokens with history tracking return documents
  • Group-managed tokens include group power information
§Arguments
  • freeze_tokens_transition_builder - Builder containing freeze parameters
  • signing_key - The identity public key for signing the transition
  • signer - Implementation of the Signer trait for cryptographic signing
§Returns

Returns a Result containing a FreezeResult on success, or an Error on failure.

§Errors

This function will return an error if:

  • The transition signing fails
  • Broadcasting the transition fails
  • The proof verification returns an unexpected result type
Source§

impl Sdk

Source

pub async fn token_mint<S: Signer<IdentityPublicKey>>( &self, mint_tokens_transition_builder: TokenMintTransitionBuilder, signing_key: &IdentityPublicKey, signer: &S, ) -> Result<MintResult, Error>

Mints new tokens according to the token’s configuration.

This method broadcasts a mint transition to create new tokens and allocate them to the specified recipient. The result varies based on token configuration:

  • Standard tokens return the recipient’s new balance
  • Tokens with history tracking return documents
  • Group-managed tokens include group power and action status
§Arguments
  • mint_tokens_transition_builder - Builder containing mint parameters including amount and recipient
  • signing_key - The identity public key for signing the transition
  • signer - Implementation of the Signer trait for cryptographic signing
§Returns

Returns a Result containing a MintResult on success, or an Error on failure.

§Errors

This function will return an error if:

  • The transition signing fails
  • Broadcasting the transition fails
  • The proof verification returns an unexpected result type
Source§

impl Sdk

Source

pub async fn token_set_price_for_direct_purchase<S: Signer<IdentityPublicKey>>( &self, set_price_transition_builder: TokenChangeDirectPurchasePriceTransitionBuilder, signing_key: &IdentityPublicKey, signer: &S, ) -> Result<SetPriceResult, Error>

Sets or updates the pricing schedule for direct token purchases.

This method broadcasts a set price transition to define how tokens can be purchased directly. The pricing schedule can include fixed prices or dynamic pricing rules. The result varies based on token configuration:

  • Standard tokens return the pricing schedule
  • Tokens with history tracking return documents
  • Group-managed tokens include group power and action status
§Arguments
  • set_price_transition_builder - Builder containing pricing parameters
  • signing_key - The identity public key for signing the transition
  • signer - Implementation of the Signer trait for cryptographic signing
§Returns

Returns a Result containing a SetPriceResult on success, or an Error on failure.

§Errors

This function will return an error if:

  • The transition signing fails
  • Broadcasting the transition fails
  • The proof verification returns an unexpected result type
Source§

impl Sdk

Source

pub async fn token_transfer<S: Signer<IdentityPublicKey>>( &self, transfer_tokens_transition_builder: TokenTransferTransitionBuilder, signing_key: &IdentityPublicKey, signer: &S, ) -> Result<TransferResult, Error>

Transfers tokens from one identity to another.

This method broadcasts a transfer transition to move tokens between identities. The result varies based on token configuration:

  • Standard tokens return updated balances for the affected identities
  • Tokens with history tracking return documents
  • Group-managed tokens include group power information
§Arguments
  • transfer_tokens_transition_builder - Builder containing transfer parameters including recipient and amount
  • signing_key - The identity public key for signing the transition
  • signer - Implementation of the Signer trait for cryptographic signing
§Returns

Returns a Result containing a TransferResult on success, or an Error on failure.

§Errors

This function will return an error if:

  • The transition signing fails
  • Broadcasting the transition fails
  • The proof verification returns an unexpected result type
Source§

impl Sdk

Source

pub async fn token_unfreeze_identity<S: Signer<IdentityPublicKey>>( &self, unfreeze_tokens_transition_builder: TokenUnfreezeTransitionBuilder, signing_key: &IdentityPublicKey, signer: &S, ) -> Result<UnfreezeResult, Error>

Unfreezes tokens for a specific identity.

This method broadcasts an unfreeze transition to restore transfer capabilities for previously frozen tokens. The result varies based on token configuration:

  • Standard tokens return identity info
  • Tokens with history tracking return documents
  • Group-managed tokens include group power information
§Arguments
  • unfreeze_tokens_transition_builder - Builder containing unfreeze parameters
  • signing_key - The identity public key for signing the transition
  • signer - Implementation of the Signer trait for cryptographic signing
§Returns

Returns a Result containing an UnfreezeResult on success, or an Error on failure.

§Errors

This function will return an error if:

  • The transition signing fails
  • Broadcasting the transition fails
  • The proof verification returns an unexpected result type
Source§

impl Sdk

Source

pub fn new_mock() -> Self

Initialize Dash Platform SDK in mock mode.

This is a helper method that uses SdkBuilder to initialize the SDK in mock mode.

See also SdkBuilder.

Source

pub fn verify_response_metadata( &self, method_name: &str, metadata: &ResponseMetadata, ) -> Result<(), Error>

Check that response metadata is fresh: its time within the time tolerance, and its height not too far below the highest height seen so far.

Pass only the metadata of an answer whose proof and quorum signature were verified: its height raises the height every later answer is checked against, for this SDK and its clones.

Protocol versions are learned only from answers the SDK verified itself, so this changes neither Self::version nor the network version the SDK has verified, whatever metadata.protocol_version says.

Source

pub async fn refresh_protocol_version(&self) -> Result<u32, Error>

Eagerly teach this SDK the network’s current protocol version and ratchet up to it.

Issues ordinary proven getEpochsInfo queries ([ExtendedEpochInfo::fetch_current]) and discards the epoch payload. The protocol version those queries carry in their verified response metadata is ratcheted in by the same Self::maybe_update_protocol_version path every other query uses — only after proof + quorum-signature verification succeeds. Refresh therefore inherits the exact cryptographic trust of ordinary traffic; it adds no second, weaker source of truth.

On a pinned SDK (SdkBuilder::with_version, version_pinned on) this issues no request and returns the pinned version.

If the fetch fails the failure is non-fatal: whatever version was already learned is kept — we never fall back to an unverified one. Note that [ExtendedEpochInfo::fetch_current] makes more than one round trip, and each verified response ratchets the version on its own. A refresh that ends in an error may therefore still have raised the stored version, and the value returned here reflects that. This is by construction: every ratchet step is proof-verified and upward-only, so a partial refresh can only ever leave the SDK closer to the network’s real version.

On a proofs-disabled SDK (SdkBuilder::with_proofs(false)) this is a no-op that returns the current version: refresh relies on a proven query, so with proofs off there is no trusted source to ratchet from.

Returns the SDK’s protocol version number after the (possible) ratchet.

Source

pub fn context_provider(&self) -> Option<impl ContextProvider>

Return ContextProvider used by the SDK.

Source

pub fn mock(&mut self) -> MutexGuard<'_, MockDashPlatformSdk>

Returns a mutable reference to the MockDashPlatformSdk instance.

Use returned object to configure mock responses with methods like expect_fetch.

§Panics

Panics when:

  • the self instance is not a Mock variant,
  • the self instance is in use by another thread.
Source

pub async fn get_identity_nonce( &self, identity_id: Identifier, bump_first: bool, settings: Option<PutSettings>, ) -> Result<IdentityNonce, Error>

Get or fetch identity nonce, querying Platform when stale or absent. Treats a missing nonce as 0 before applying the optional bump; on first interaction this may return 0 or 1 depending on bump_first. Does not verify identity existence.

Source

pub async fn get_identity_contract_nonce( &self, identity_id: Identifier, contract_id: Identifier, bump_first: bool, settings: Option<PutSettings>, ) -> Result<IdentityNonce, Error>

Get or fetch identity-contract nonce, querying Platform when stale or absent. Treats a missing nonce as 0 before applying the optional bump; on first interaction this may return 0 or 1 depending on bump_first. Does not verify identity or contract existence.

Source

pub async fn refresh_identity_nonce(&self, identity_id: &Identifier)

Marks identity nonce cache entries as stale so they are re-fetched from Platform on the next call to [get_identity_nonce] or [get_identity_contract_nonce].

Source

pub fn version<'v>(&self) -> &'v PlatformVersion

Return Dash Platform version information used by this SDK.

With auto-detection (default) the SDK starts at the per-network min_protocol_version (or the seed set via SdkBuilder::with_initial_version) and then tracks the network’s version — auto-detection only ever ratchets upward (fetch_max). A version pinned via SdkBuilder::with_version() is returned as pinned.

Source

pub fn protocol_version_number(&self) -> u32

Return the raw protocol version number currently used by this SDK.

Source

pub fn protocol_version_info(&self) -> ProtocolVersionInfo

Read the cached verified observation without making a request. Ordinary proved queries update it even when the operation version is pinned.

Source

pub fn prove(&self) -> bool

Indicate if the sdk should request and verify proofs.

Source

pub fn query_settings(&self) -> QuerySettings<'_>

Build a [QuerySettings] borrowing this SDK’s protocol version and prove flag.

Hand the resulting context to crate::platform::Query::query when you need to encode a user-facing query into a wire TransportRequest without taking a full &Sdk dependency through the encoder layer.

Its protocol version is Self::version, except that an unpinned SDK on a network a verified answer showed runs a version this build does not know encodes with the newest version it knows, the rules it reads those answers with.

Source

pub fn set_context_provider<C: ContextProvider + 'static>( &self, context_provider: C, )

Set the ContextProvider to use.

ContextProvider is used to access state information, like data contracts and quorum public keys.

Note that this will overwrite any previous context provider.

Source

pub fn cancelled(&self) -> WaitForCancellationFuture<'_> ⓘ

Returns a future that resolves when the Sdk is cancelled (e.g. shutdown was requested).

Source

pub fn shutdown(&self)

Request shutdown of the Sdk and all related operations.

Source

pub fn address_list(&self) -> &AddressList

Return the [DapiClient] address list

Source

pub fn address_ban_info(&self) -> Vec<AddressBanInfo>

Return an owned snapshot of every DAPI address’ ban state, including the reason the address was banned (when recorded).

Delegates to AddressList::ban_info. Useful for diagnostics and surfacing ban state up through the platform-wallet FFI to the iOS example app.

Trait Implementations§

Source§

impl Clone for Sdk

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl DapiRequestExecutor for Sdk

Source§

fn execute<'life0, 'async_trait, R>( &'life0 self, request: R, settings: RequestSettings, ) -> Pin<Box<dyn Future<Output = ExecutionResult<R::Response, DapiClientError>> + Send + 'async_trait>>
where R: 'async_trait + TransportRequest, Self: 'async_trait, 'life0: 'async_trait,

Execute request using this DAPI client.
Source§

impl Debug for Sdk

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl IdentityCreateFromShieldedPool for Sdk

Source§

fn identity_create_from_shielded_pool_transition( &self, public_keys: Vec<IdentityPublicKeyInCreation>, denomination: u64, send_to_address_on_creation_failure: PlatformAddress, bundle: OrchardBundleParams, ) -> Result<StateTransition, Error>

Build (and structurally validate) the Type-20 transition from PoP-signed keys + bundle params, without broadcasting it. Read more
Source§

fn identity_create_from_shielded_pool<'life0, 'async_trait>( &'life0 self, public_keys: Vec<IdentityPublicKeyInCreation>, denomination: u64, send_to_address_on_creation_failure: PlatformAddress, bundle: OrchardBundleParams, settings: Option<PutSettings>, ) -> Pin<Box<dyn Future<Output = Result<StateTransitionProofResult, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create a new identity funded by spending shielded-pool notes. Read more
Source§

impl IdentityTopUpFromShieldedPool for Sdk

Source§

fn identity_top_up_from_shielded_pool_transition( &self, identity_id: Identifier, top_up_amount: u64, bundle: OrchardBundleParams, ) -> Result<StateTransition, Error>

Build and structure-check the transition without broadcasting it.
Source§

fn identity_top_up_from_shielded_pool<'life0, 'async_trait>( &'life0 self, identity_id: Identifier, top_up_amount: u64, bundle: OrchardBundleParams, settings: Option<PutSettings>, ) -> Pin<Box<dyn Future<Output = Result<StateTransitionProofResult, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Build, broadcast, and wait for proven execution. Returns the VerifiedIdentityWithShieldedNullifiers proof result (the credited identity and the spent nullifiers), so a wallet only marks notes spent once the top-up is cryptographically proven included.
Source§

impl ShieldFromAssetLock for Sdk

Source§

fn shield_from_asset_lock<'life0, 'life1, 'async_trait>( &'life0 self, asset_lock_proof: AssetLockProof, asset_lock_proof_private_key: &'life1 [u8], bundle: OrchardBundleParams, value_balance: u64, surplus_output: Option<PlatformAddress>, settings: Option<PutSettings>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Shield funds from an L1 asset lock into the shielded pool. The asset lock proof proves ownership of L1 funds, and the ECDSA signature binds those funds to this specific Orchard bundle. Read more
Source§

impl<S: Signer<PlatformAddress>> ShieldFunds<S> for Sdk

Source§

fn shield_funds<'life0, 'life1, 'async_trait>( &'life0 self, inputs: BTreeMap<PlatformAddress, Credits>, bundle: OrchardBundleParams, amount: u64, fee_strategy: AddressFundsFeeStrategy, signer: &'life1 S, settings: Option<PutSettings>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Shield funds from platform addresses into the shielded pool. Address nonces are fetched automatically.
Source§

fn shield_funds_with_nonce<'life0, 'life1, 'async_trait>( &'life0 self, inputs: BTreeMap<PlatformAddress, (AddressNonce, Credits)>, bundle: OrchardBundleParams, amount: u64, fee_strategy: AddressFundsFeeStrategy, signer: &'life1 S, settings: Option<PutSettings>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Shield funds with explicitly provided address nonces.
Source§

impl<S: Signer<PlatformAddress>> TransferAddressFunds<S> for Sdk

Source§

fn transfer_address_funds<'life0, 'life1, 'async_trait>( &'life0 self, inputs: BTreeMap<PlatformAddress, Credits>, outputs: BTreeMap<PlatformAddress, Credits>, fee_strategy: AddressFundsFeeStrategy, signer: &'life1 S, settings: Option<PutSettings>, ) -> Pin<Box<dyn Future<Output = Result<(AddressInfos, u64), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Broadcast address funds transfer (nonces looked up automatically) and return refreshed balances.
Source§

fn transfer_address_funds_with_nonce<'life0, 'life1, 'async_trait>( &'life0 self, inputs: BTreeMap<PlatformAddress, (AddressNonce, Credits)>, outputs: BTreeMap<PlatformAddress, Credits>, fee_strategy: AddressFundsFeeStrategy, signer: &'life1 S, settings: Option<PutSettings>, ) -> Pin<Box<dyn Future<Output = Result<(AddressInfos, u64), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Broadcast address funds transfer with explicitly provided address nonces. Read more
Source§

impl TransferShielded for Sdk

Source§

fn transfer_shielded<'life0, 'async_trait>( &'life0 self, bundle: OrchardBundleParams, value_balance: u64, settings: Option<PutSettings>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Transfer funds within the shielded pool. Authentication is via Orchard spend authorization signatures in the bundle actions.
Source§

impl UnshieldFunds for Sdk

Source§

fn unshield_funds<'life0, 'async_trait>( &'life0 self, output_address: PlatformAddress, unshielding_amount: u64, bundle: OrchardBundleParams, settings: Option<PutSettings>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Unshield funds from the shielded pool to a platform address. Authentication is via Orchard spend authorization signatures in the bundle actions.
Source§

impl<S: Signer<PlatformAddress>> WithdrawAddressFunds<S> for Sdk

Source§

fn withdraw_address_funds<'life0, 'life1, 'async_trait>( &'life0 self, inputs: BTreeMap<PlatformAddress, Credits>, change_output: Option<(PlatformAddress, Credits)>, fee_strategy: AddressFundsFeeStrategy, core_fee_per_byte: u32, pooling: Pooling, output_script: CoreScript, signer: &'life1 S, settings: Option<PutSettings>, ) -> Pin<Box<dyn Future<Output = Result<(AddressInfos, u64), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Withdraws address balances (nonces fetched automatically).
Source§

fn withdraw_address_funds_with_nonce<'life0, 'life1, 'async_trait>( &'life0 self, inputs: BTreeMap<PlatformAddress, (AddressNonce, Credits)>, change_output: Option<(PlatformAddress, Credits)>, fee_strategy: AddressFundsFeeStrategy, core_fee_per_byte: u32, pooling: Pooling, output_script: CoreScript, signer: &'life1 S, settings: Option<PutSettings>, ) -> Pin<Box<dyn Future<Output = Result<(AddressInfos, u64), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Withdraws address balances with explicitly provided nonces. Read more
Source§

impl WithdrawShielded for Sdk

Source§

fn withdraw_shielded<'life0, 'async_trait>( &'life0 self, unshielding_amount: u64, bundle: OrchardBundleParams, core_fee_per_byte: u32, pooling: Pooling, output_script: CoreScript, settings: Option<PutSettings>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Withdraw funds from the shielded pool to a Core address. Authentication is via Orchard spend authorization signatures in the bundle actions.

Auto Trait Implementations§

§

impl !Freeze for Sdk

§

impl !RefUnwindSafe for Sdk

§

impl !UnwindSafe for Sdk

§

impl Send for Sdk

§

impl Sync for Sdk

§

impl Unpin for Sdk

§

impl UnsafeUnpin for Sdk

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Conv for T

§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
§

impl<T> CostsExt for T

§

fn wrap_with_cost(self, cost: OperationCost) -> CostContext<Self>
where Self: Sized,

Wraps any value into a CostContext object with provided costs.
§

fn wrap_fn_cost( self, f: impl FnOnce(&Self) -> OperationCost, ) -> CostContext<Self>
where Self: Sized,

Wraps any value into CostContext object with costs computed using the value getting wrapped.
§

impl<T> FmtForward for T

§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T, U> IntoOnNetwork<U> for T
where U: FromOnNetwork<T>,

§

fn into_on_network(self, network: Network) -> U

Calls U::from_on_network(self).

§

impl<T, U> IntoPlatformVersioned<U> for T
where U: FromPlatformVersioned<T>,

§

fn into_platform_versioned(self, platform_version: &PlatformVersion) -> U

Performs the conversion.
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Pipe for T
where T: ?Sized,

§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> Tap for T

§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T> TryConv for T

§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryFromVersioned<U> for T
where T: TryFrom<U>,

§

type Error = <T as TryFrom<U>>::Error

The type returned in the event of a conversion error.
§

fn try_from_versioned( value: U, _grove_version: &GroveVersion, ) -> Result<T, <T as TryFromVersioned<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T, U> TryIntoPlatformVersioned<U> for T
where U: TryFromPlatformVersioned<T>,

§

type Error = <U as TryFromPlatformVersioned<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into_platform_versioned( self, platform_version: &PlatformVersion, ) -> Result<U, <U as TryFromPlatformVersioned<T>>::Error>

Performs the conversion.
§

impl<T, U> TryIntoVersioned<U> for T
where U: TryFromVersioned<T>,

§

type Error = <U as TryFromVersioned<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into_versioned( self, grove_version: &GroveVersion, ) -> Result<U, <U as TryFromVersioned<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more