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 shows whatever the RPC returns, including failures. These two live calls to Sei Mainnet fail on purpose. They show the exact error shape that your code has to handle.

Contract reverts

When a transaction reverts and the contract gives a revert reason, the error contains that reason.

Simulating before sending

Always simulate write calls before you submit them. Simulation runs the call against the current chain state and reports 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

This utility handles the most common cases in one place:

RPC errors and retries

You can retry transient RPC failures, such as network timeouts and rate limits. Do not retry contract reverts or user rejections. Those failures are deterministic.