Skip to main content

Error codes

Every CrackPay request that fails rejects with an error that has a numeric code. Match on the code, never on the message: messages may change.

CodeErrorCode.MeaningTell the user
4001UserRejectedCancelled the confirmation or the passkey prompt"Cancelled." Let them retry.
4100UnauthorizedNot allowed for this app: a contract outside its listing, or a forbidden token callGeneric failure. It is a bug or a missing listing entry.
4200UnsupportedMethodThe method is not supportedDo not call it. See Provider methods.
4902UnrecognizedChainAsked for a chain other than ArcDo not switch chains.
-32602InvalidParamsMalformed requestFix the request.
-32603InternalReverted, never confirmed, or a failure inside CrackPay"The payment didn't go through."

Handling errors​

import { ErrorCode, errorCode, isUserRejection } from "@crackpay/miniapp-sdk";

try {
await walletClient.writeContract(request);
} catch (error) {
if (isUserRejection(error)) return show("Cancelled.");
if (errorCode(error) === ErrorCode.Unauthorized) {
console.error("This call is not allowed for the app; check its listing", error);
}
console.error(error);
show("The payment didn't go through. Please try again.");
}

errorCode reads the code whether the error came from the provider or was wrapped by viem or wagmi.

A payment that may or may not have happened​

A -32603 whose message says the operation "was submitted but never confirmed" is special: the payment may have gone through. Tell the user to check their balance before trying again, and never retry automatically.