DappClient
The dApp side of CIP-0103: typed calls onto a DappTransport.
val client = DappClient(transport)
if (client.connect().isConnected) {
val account = client.getPrimaryAccount()
val tx = client.prepareExecuteAndWait(PrepareSubmission(commands = commands))
println(tx.updateId)
}Every method throws DappException when the wallet returns a JSON-RPC error, so 4001 (the user declined) arrives as an exception with DappException.isUserRejection set rather than as a null that is easy to mistake for "nothing happened".
This class holds no session state. Whether a connection exists is the wallet's answer to give, and caching it here would only let the two disagree — call isConnected or status to ask.
Properties
Functions
Requests a connection. The wallet decides, typically by asking the user.
Ends the session. Idempotent by convention; wallets should not error on a repeat.
The network the wallet is currently on, as a CAIP-2 id plus optional endpoints.
The account the wallet treats as primary, among those granted.
Whether a connection exists, without prompting the user.
Calls the JSON Ledger API through the wallet, which supplies the credentials. The wallet applies its own policy — expect 4100 for resources outside it rather than assuming full ledger access.
Accounts the user has granted this dApp. Not necessarily every account the wallet holds.
Submits request and returns as soon as the wallet accepts it.
Submits request and suspends until the transaction is executed.
Convenience for callers that want the raw frame — mainly tests and diagnostics.
Asks the wallet to sign an arbitrary message. Subject to user approval.
Provider identity, connection state, and — if connected — network and session.