Skip to main content

Error Handling

Most transaction failures fall into three categories: contract reverts, wallet rejections, and RPC errors. This page shows how to decode each type and respond correctly.

Try it: see real errors

The RunSnippet widget surfaces whatever the RPC returns — including failures. These two calls fail on purpose so you can see the exact error shape your code has to handle, live against Sei mainnet.

Contract Reverts

When a transaction reverts, the error contains the revert reason if the contract provides one.

Simulating Before Sending

Always simulate write calls before submitting them. Simulation runs the call against current chain state and surfaces reverts before you spend gas:
viem

Wallet Rejections

Users can reject signature and transaction requests. These rejections have a predictable error code:

Insufficient Funds

Classifying Any Error

A utility to handle the most common cases in one place:

RPC Errors and Retries

Transient RPC failures (network timeouts, rate limits) can be retried. Don’t retry on contract reverts or user rejections — those are deterministic.