Skip to main content
For the complete documentation index, see llms.txt

DApp Connector API errors

The Midnight DApp Connector is the browser-based API that connects DApps to supported wallets such as Lace and 1AM.

This reference covers the error codes that the DApp Connector API returns when a DApp interacts with the wallet. Errors surface as APIError objects with a type field, not as instanceof checks. Always use error.type === 'DAppConnectorAPIError' to identify them.

Error codes (v4.0.x)

The following error codes are available in the current version of the DApp Connector API.

CodeDescriptionScopeFix
DisconnectedConnection to the wallet was lost mid-session.Session-levelRe-establish the connection by calling enable() again.
InternalErrorConnector could not process the request internally.InternalRetry the operation; check Lace wallet logs and update the wallet extension if needed.
InvalidRequestMalformed transaction or invalid request parameters.Client errorVerify the transaction structure; check parameter types and formats.
PermissionRejectedUsers have set a session-level preference to deny this DApp.PersistentAsk users to unblock the DApp in their wallet settings.
RejectedUsers saw a specific request and declined this time.Per-requestTell users they cancelled the action; do not auto-retry.

Key distinction: Rejected vs. PermissionRejected

These two codes both represent user rejection, but differ in scope and how to respond.

  • Rejected: Users saw the specific transaction or request and declined this time. The DApp can try again with a different request.
  • PermissionRejected: Users have set a session-level preference to deny this DApp entirely. Retrying produces the same result until users change their wallet settings.

Detecting APIError

Use error.type to identify DApp Connector API errors. Do not use instanceof checks, as APIError is not a class you can test against.

// Use the type field to identify connector errors
if (error.type === 'DAppConnectorAPIError') {
switch (error.code) {
case 'Rejected': // user declined
case 'PermissionRejected': // user blocked DApp
case 'InvalidRequest': // bad request
case 'InternalError': // internal failure
case 'Disconnected': // connection lost
}
}

// Do NOT use instanceof
// if (error instanceof APIError) { ... }

Structure of APIError

The APIError type extends the native Error object with the following fields.

type APIError = Error & {
type: 'DAppConnectorAPIError';
code: ErrorCode; // one of the 5 codes above
reason: string; // human-readable explanation
}

Transaction status types

The DApp Connector also reports transaction status through these values.

StatusDescription
finalizedConsensus has finalized the transaction.
confirmedTransaction included in a block but not yet finalized.
pendingTransaction submitted, awaiting block inclusion.
discardedThe node discarded the transaction (not included).