Public API: C8WalletProvider
| Method | Parameters | Return Type |
|---|---|---|
connect() | None | Promise<void> |
disconnect() | None | Promise<void> |
status() | None | Promise<{ connected: boolean; walletVersion?: string }> |
getInstruments() | None | Promise<InstrumentListPayload> |
getAccounts() | instrumentId?: string | Promise<AccountListPayload> |
send() | input: SendInput | Promise<SubmitTransferResultPayload> |
signAndExecute() | input: SignAndExecuteInput | Promise<void> |
checkTxStatusById() | input: { txId: string } | Promise<TransferStatusResponsePayload> |
on() | event: T, cb: Listener<C8EventByType<T>> | () => boolean |
Constructor
Creates a new wallet provider instance.URL of the dApp initiating the connection. Defaults to the current page URL.
Name of the dApp. Must match the name registered with the wallet.
Canton network to connect to. One of
"devnet" or "mainnet".connect
Opens the C8 Wallet popup and establishes thepostMessage channel. The user sees a connection approval screen in the wallet.
Resolves when the user approves the connection.
Must be called from a user gesture (e.g. 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.Whether the wallet is currently connected.
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.
Optional. Filters accounts to those holding this instrument.
send
Submits a transfer on the Canton ledger. Opens an approval screen in the wallet popup.Canton
partyId of the sender.Asset to transfer.
Transfer amount.
Canton
partyId of the recipient.Optional text memo attached to the transfer.
Optional arbitrary key-value metadata.
Transaction ID assigned by the Canton ledger. Use it with
checkTxStatusById.signAndExecute
Signs and executes an arbitrary DAML command via the connected wallet. Use this for custom templates and choices beyond standard transfers. See Transfer types for the full example.Human-readable note shown to the user in the wallet UI.
The party submitting the command.
Unique idempotency key for this submission (e.g. a UUID).
JSON-serialized array of DAML commands (
CreateCommand, ExerciseCommand, etc.).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.Event type to subscribe to (e.g.
"connected", "txChanged").Callback invoked with the typed event payload.
Unsubscribe function. Call it to remove the listener.
checkTxStatusById
Polls the Canton ledger for the current status of a previously submitted transaction.Transaction ID returned by
send().Current ledger status for the given transaction.
