Skip to content

SpliceProvider

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

SpliceProvider interface for dApp ↔ Wallet communication.

Exposed to dApps as window.canton. Follows the EIP-1193 style pattern with request/on/emit/removeListener methods.

request: TypedRequestFn

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

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:62

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:53

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:71

Unsubscribe from wallet events.

T = unknown

string

Event name

EventListener<T>

Callback function to remove

SpliceProvider

Provider instance for chaining