Public API: C8WalletProvider
Constructor
Creates a new wallet provider instance.string
URL of the dApp initiating the connection. Defaults to the current page origin.
string
required
Name of the dApp. Must match the name registered with the wallet.
string
Canton network to connect to. Use
"devnet", "testmainnet", or "mainnet". Defaults to "mainnet".connect
Opens the C8 Wallet popup and establishes thepostMessage channel. The user sees a connection approval screen in the wallet.
Promise<void>
Resolves when the user approves the connection.
Call interactive methods from a user gesture, such as a button click, to avoid
POPUP_BLOCKED errors.disconnect
Closes the wallet popup and tears down thepostMessage channel. Emits the disconnected event.
status
Returns the current connection state.boolean
Whether the wallet is currently connected.
string
Version of the connected wallet (only present when connected).
getInstruments
Returns the list of Canton instruments available in the connected wallet.getAccounts
Returns accounts and their holdings. IfinstrumentId is provided, filters to accounts holding that instrument.
string
Optional. Filters accounts to those holding this instrument.
string
Optional display name for the account.
string
Canton party identifier for the account.
string
Public key associated with the account.
ValidatorInfo
Validator assigned to the account as
{ id: string, name: string }.send
Submits a transfer on the Canton ledger. Opens an approval screen in the wallet popup.string
required
Canton
partyId of the sender.string
required
Asset to transfer.
number
required
Transfer amount.
string
required
Canton
partyId of the recipient.string
Optional text memo attached to the transfer.
Record<string, string>
Optional arbitrary key-value metadata.
string
Transaction ID assigned by the Canton ledger. Use it with
checkTxStatusById.createSwapOffer
Creates a multi-leg swap offer and opens the wallet approval UI. Amounts in swap legs are decimal strings.string
required
Party creating the swap offer.
string
Optional idempotency key for the submission.
string
required
Unique identifier for the swap.
string
required
Party allowed to accept the swap.
SwapLegRequest[]
required
Assets the creator provides. Each leg contains
receiver, instrument, amount, legId, and an optional reason.SwapLegRequest[]
required
Assets the acceptor provides. Each leg uses the same shape as a creator leg.
SwapTransferLegRequest[]
required
Additional transfer legs supplied by the creator. Pass an empty array when the swap has none.
string
required
ISO 8601 timestamp after which the swap can no longer settle.
Record<string, string>
required
Application metadata for the swap. Pass an empty object when you have no metadata.
string
Transaction ID assigned after the wallet submits the swap offer.
signMessage
Asks the wallet to sign an arbitrary string. You can bind the request to a specific account by passing its party ID.string
required
Message to show in the wallet approval UI and sign.
string
Optional party whose account should sign the message.
Promise<string>
Signature string returned by the wallet.
signAndExecute
Signs and executes custom DAML commands via the connected wallet. Use this for templates, choices, and contract workflows beyond the SDK’s high-level methods. See Transactions and signing for the full example.string
required
Human-readable note shown to the user in the wallet UI.
string
required
The party submitting the command.
string
required
Unique idempotency key for this submission (e.g. a UUID).
string
required
JSON-serialized array of DAML commands (
CreateCommand, ExerciseCommand, etc.).string
required
JSON-serialized array of contracts disclosed to the participant to authorize the command.
on
Subscribes to a wallet event. Returns an unsubscribe function. See Events for the full event reference.string
required
Event type to subscribe to (e.g.
"connected", "txChanged").Listener
required
Callback invoked with the typed event payload.
() => boolean
Unsubscribe function. Call it to remove the listener.
checkTxStatusById
Polls the Canton ledger for the current status of a previously submitted transaction.string
required
Transaction ID returned by
send().Promise<TransferStatusResponsePayload>
Current ledger status for the given transaction.
