Skip to content

Errors

Error shape

When a wallet request fails, the promise rejects with a plain object (not an Error instance):

ts
{
    status: 'error' | 'fail',
    code: number,
    message: string,
    data?: unknown, // extra detail, e.g. which parameter was invalid
}
  • status: 'fail': usually the request itself was invalid (bad parameters), though the extension also uses it for a few busy or internal conditions. Branch on code, not status.
  • status: 'error': the request could not be completed. The user rejected it, the wallet was busy, the transaction failed, and so on.

For wallet errors, message is the generic text for the code. Extra detail, such as the chain's error for a failed transaction, is in data.

A few SDK-side checks throw a regular Error instead. These are the environment mismatch on connect(), and Not supported in web provider for getNetwork(), getNetworks() and switchNetwork() with the Web Wallet. Those three throw synchronously, so catch them with try { await … } rather than .catch(). Handle both kinds:

ts
import { SdkErrorCode } from '@ultraos/wallet-sdk';

try {
    await wallet.signTransaction(tx);
} catch (err: any) {
    if (err instanceof Error) {
        showError(err.message); // SDK configuration / unsupported method
    } else if (err?.code === SdkErrorCode.USER_REJECTED_REQUEST) {
        // 4001: the user said no. Usually no error message is needed.
    } else {
        showError(err?.message ?? 'Wallet request failed');
    }
}

Wallet error codes

The codes follow EIP-1193 and EIP-1474.

CodeNameTypical cause
4001User rejected requestThe user clicked Cancel or Reject. Also connect({ onlyIfTrusted: true }) on an untrusted origin. With the Web Wallet, closing the popup rejects with 4001 too. With the extension, closing the approval window leaves the request pending: the user can reopen the extension to approve or reject it.
4100UnauthorizedThe origin is not connected, for example signMessage(), signTransaction() or switchNetwork() before connect(), or a Web Wallet disconnect() from an origin that is not connected.
4900DisconnectedReserved. Not currently raised by either wallet.
4902Unrecognized chain IDswitchNetwork() to a network the wallet does not have.
-32000Invalid inputMissing or invalid parameters, such as an invalid transaction object, authorizations with no valid account@permission (Web Wallet), or (extension) a message without a message: / 0x / UOSx prefix.
-32002Resource unavailableThe wallet is busy: a duplicate connect(), a pending request blocking switchNetwork(), or the wallet is locked.
-32003Transaction rejectedSigning or broadcasting failed. The chain's error is in data. The Web Wallet also uses this code for a message or nonce with an invalid prefix, after the user confirms.
-32005Limit exceededMore than 10 pending requests from your origin.
-32600Invalid requestThe request object is malformed.
-32601Method not foundThe wallet does not implement the method, for example getAccounts() with the Web Wallet, or a removed method called directly on window.ultra.
-32602Invalid paramsA parameter has the wrong format, such as a switchNetwork() chain ID that is not 64 hex characters.
-32603Internal errorAn unexpected wallet-side failure.

SDK error codes

The SDK raises these codes itself. Most come from the Web Wallet's popup transport. They are exported as SdkErrorCode:

CodeSdkErrorCodeMessageCause
4001USER_REJECTED_REQUESTThe user rejected the request.The user closed the Web Wallet popup before finishing.
4300WALLET_HANDSHAKE_TIMEOUTTimeout to connect with the web wallet.The popup did not respond within 10 seconds. The SDK closes it.
4301WALLET_WINDOW_UNAVAILABLEWallet window blocked by browser or failed to open.The popup was blocked. Call from a user gesture.
4302WEB_WALLET_UNAVAILABLEThe Ultra Web Wallet is not available on this network. …SDK 0.6.1+. The Web Wallet provider was used with environment: 'testnet'. Testnet is supported through the browser extension only.
32002REQUESTED_RESOURCE_NOT_AVAILABLERequested resource not available.A Web Wallet request is already in progress. Note: this is positive 32002, unlike the extension's -32002.
-32604UNKNOWN_ERRORUnknown error occurred.The popup's JSON-RPC call failed without an error code. The original error is in data. When the Web Wallet returns a coded JSON-RPC error (such as -32601), SDK 0.6.1+ rejects with that code and closes the popup. (SDK 0.6.0 rejected with undefined, so guard with err?.code.)