Skip to main content
There are two ways to interact with the dApp API:
  1. 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.
  2. 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.
The examples below show both approaches side by side.

Setup

dApp SDK: Import the dApp SDK:
Call init() once early (e.g. on app mount). This registers adapters and attempts to restore a previously connected session without opening the wallet picker.
If you want to add or replace wallets (e.g. WalletConnect), see Adapter registration & wallet discovery (picker). Provider API: Import and create a provider instance:

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:
Provider API:

Disconnecting from a Wallet

Close the session between the client and the Wallet. dApp SDK:
Provider API:

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:
Provider API:

Checking if Connected (without login)

Check if the user is connected without triggering the login flow. dApp SDK:
Provider API:

Getting the Active Network

Retrieve details about the network the user is connected to. dApp SDK:
Provider API:

Listing Accounts

List all accounts (parties) the user has access to in the Wallet. dApp SDK:
Provider API:

Getting the Primary Account

Get the account currently set as primary by the user. dApp SDK:
Provider API:

Signing a Message

Sign an arbitrary string message using the primary account’s private key. dApp SDK:
Provider API:

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:
Provider API:

Calling the Ledger API

Proxy requests to the Canton JSON Ledger API. The request is authenticated using the user’s session. dApp SDK:
Provider API:

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:
Provider API:

Listening for Account Changes

Receive notifications when accounts are added, removed, or when the primary account changes. dApp SDK:
Provider API:

Listening for Transaction Changes

Receive notifications about the lifecycle of transactions initiated via prepareExecute. The event payload includes the transaction status (pending, signed, executed, failed) and relevant details. dApp SDK:
Provider API:

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:
Provider API:

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).

Adapter registration & wallet discovery (picker)

See Adapter registration & wallet discovery (picker) for multiple ways to register adapters and what appears in the wallet picker.