- dApp SDK - A high-level SDK that wraps the Provider API with convenient methods and event handlers. This is the recommended approach for most applications.
- Provider API - The low-level interface that follows the EIP-1193 pattern. Use this when you need direct control over the API or are integrating with existing provider-based infrastructure.
Setup
dApp SDK: Import the dApp SDK:Initialize the SDK (recommended)
Callinit() once early (e.g. on app mount). This registers adapters and attempts
to restore a previously connected session without opening the wallet picker.
Request-Response Methods
Connecting to a Wallet
Establish a connection to the Wallet. This initiates the authentication flow if the user is not already authenticated. dApp SDK:Disconnecting from a Wallet
Close the session between the client and the Wallet. dApp SDK:Checking the Connection Status
Check the connection status of the Wallet. The status returns an object containing network connection- and session-related information. dApp SDK:Checking if Connected (without login)
Check if the user is connected without triggering the login flow. dApp SDK:Getting the Active Network
Retrieve details about the network the user is connected to. dApp SDK:Listing Accounts
List all accounts (parties) the user has access to in the Wallet. dApp SDK:Getting the Primary Account
Get the account currently set as primary by the user. dApp SDK:Signing a Message
Sign an arbitrary string message using the primary account’s private key. dApp SDK:Executing a Transaction
Prepare, sign, and execute a Daml transaction. This method handles the full lifecycle: preparing the commands, requesting user approval/signature, and submitting to the ledger. dApp SDK:Calling the Ledger API
Proxy requests to the Canton JSON Ledger API. The request is authenticated using the user’s session. dApp SDK:Events
The dApp API emits events to notify your application of state changes. Subscribe to these events to keep your UI in sync with the Wallet state.Listening for Connection Status Changes
Receive notifications when the connection status or session state changes. dApp SDK:Listening for Account Changes
Receive notifications when accounts are added, removed, or when the primary account changes. dApp SDK:Listening for Transaction Changes
Receive notifications about the lifecycle of transactions initiated viaprepareExecute. The event payload includes the transaction status (pending, signed, executed, failed) and relevant details.
dApp SDK:
Removing Event Listeners
When your component unmounts or you no longer need to listen for events, remove the listeners to prevent memory leaks. dApp SDK:Adapter / Provider information
Get the current provider
sdk.getConnectedProvider() returns the raw CIP-103 provider for the currently active
discovery session, or null if you are not connected. Use this when you need direct
access to provider.request(...), to subscribe to provider-level events, or to
instantiate the Wallet SDK (upcoming feature).