Error Handling
The SDK exports typed error classes for targeted recovery. Simulation errors automatically surface the human-readable revert reason — no manual ABI decoding required.
TS
import { SimulationError, // contract reverted during simulation (before gas is spent) ContractExecutionError, // broadcast or receipt error GasEstimationError, // gas estimation failed ApiKeyRequiredError, // missing API key InvalidApiKeyError, // revoked or malformed key UnsupportedChainError, // chain string not recognised WalletNotConnectedError,// write attempted with no wallet } from "@awarizon/web3" try { await usdc.transfer(to, amount) } catch (err) { if (err instanceof SimulationError) { // Revert reason extracted automatically — no hex decoding needed console.error(err.message) // → "Simulation failed: ERC20: transfer amount exceeds balance" // → "Simulation failed: MintLimitReached(500, 500)" (custom errors too) } else if (err instanceof WalletNotConnectedError) { // Prompt user to connect a wallet } else if (err instanceof InvalidApiKeyError) { // Redirect to /dashboard/api-keys } else if (err instanceof ContractExecutionError) { console.error("Execution failed:", err.message, "Function:", err.functionName) } }