Skip to content

SpliceProvider

Defined in: packages/dapp/src/provider/interface.ts:23

SpliceProvider interface for CIP-103 dApp ↔ Wallet communication.

Exposed to dApps as window.canton. CIP-103 specifies the request/on/emit/removeListener object shape (the EIP-1193 pattern) and the method/event surface; this interface implements that contract. See CIP-103.

request: TypedRequestFn

Defined in: packages/dapp/src/provider/interface.ts:46

Send a JSON-RPC request to the wallet.

Strictly typed to canonical OpenRPC methods. Use the method name as a literal type to get correct params/result types.

Typed request payload with method and params

Promise resolving to the typed method result

RPC error if request fails

// Methods without params
const status = await window.canton.request({ method: 'status' })
// status is StatusEvent
// Methods with params
const result = await window.canton.request({
method: 'prepareExecuteAndWait',
params: { commands: {...}, commandId: 'cmd-1' }
})
// result is PrepareExecuteAndWaitResult

emit<T>(event, …args): boolean

Defined in: packages/dapp/src/provider/interface.ts:67

Emit an event to all registered listeners.

T = unknown

string

Event name

T[]

Arguments to pass to listeners

boolean

true if event had listeners, false otherwise


on<T>(event, listener): SpliceProvider

Defined in: packages/dapp/src/provider/interface.ts:58

Subscribe to wallet events.

T = unknown

string

Event name (e.g., ‘accountsChanged’, ‘txChanged’)

EventListener<T>

Callback function

SpliceProvider

Provider instance for chaining

window.canton.on('accountsChanged', (accounts) => console.log(accounts))

removeListener<T>(event, listener): SpliceProvider

Defined in: packages/dapp/src/provider/interface.ts:76

Unsubscribe from wallet events.

T = unknown

string

Event name

EventListener<T>

Callback function to remove

SpliceProvider

Provider instance for chaining