A revert carries a 4-byte error selector followed by the error's arguments. To read it you need the contract's error definitions. BlazePhoenix publishes them at /api/abi?contract=errors and through the get_abi tool of its MCP server; decoding the revert data against that ABI turns the bytes into a named error.

How to read a failed swap: decoding a revert with the error ABI
How do you read a failed swap?
A failed swap returns four bytes and some data, not a sentence. How custom errors are encoded, how to decode a BlazePhoenix revert with the published errors ABI, and why many reverts protect you.
BlazePhoenix Engineering · article updated 2026-10-05 · site dataset through 2026-11-19 · 5 min · written from the deployed bytecode
| Level | Advanced |
|---|---|
| Reading time | 5 min |
| Sections | 5 |
| Updated | 2026-10-05 |
By Mitra (@Sigmacrit) — anonymous developer of the BlazePhoenix protocol. The code is the résumé.
Abstract in 15 languages · resumo · resumen · 摘要 · 要旨 · ملخص
English — A failed swap returns a 4-byte error selector and ABI-encoded arguments, not a sentence. How Solidity custom errors are encoded, where to find the revert data, how to decode a BlazePhoenix revert with viem and the published errors ABI, and why many reverts are a guard protecting your trade.
Português — Um swap falhado devolve um seletor de erro de 4 bytes e argumentos codificados em ABI, não uma frase. Como são codificados os custom errors de Solidity, onde encontrar os dados do revert, como descodificar um revert da BlazePhoenix com viem e o ABI de erros publicado, e porque é que muitos reverts são uma guarda a proteger a sua operação.
Español — Un swap fallido devuelve un selector de error de 4 bytes y argumentos codificados en ABI, no una frase. Cómo se codifican los custom errors de Solidity, dónde encontrar los datos del revert, cómo decodificar un revert de BlazePhoenix con viem y el ABI de errores publicado, y por qué muchos reverts son una guarda que protege tu operación.
Français — Un swap échoué renvoie un sélecteur d'erreur de 4 octets et des arguments encodés en ABI, pas une phrase. Comment les custom errors de Solidity sont encodées, où trouver les données du revert, comment décoder un revert de BlazePhoenix avec viem et l'ABI d'erreurs publié, et pourquoi beaucoup de reverts sont une garde qui protège votre transaction.
Deutsch — Ein fehlgeschlagener Swap liefert einen 4-Byte-Fehlerselektor und ABI-kodierte Argumente, keinen Satz. Wie Solidity-Custom-Errors kodiert sind, wo man die Revert-Daten findet, wie man einen BlazePhoenix-Revert mit viem und dem veröffentlichten Fehler-ABI dekodiert und warum viele Reverts ein Wächter sind, der Ihren Handel schützt.
Русский — Неудачный своп возвращает 4-байтовый селектор ошибки и аргументы в кодировке ABI, а не фразу. Как кодируются пользовательские ошибки (custom errors) Solidity, где найти данные revert, как декодировать revert BlazePhoenix с помощью viem и опубликованного ABI ошибок и почему многие revert — это страж, защищающий вашу сделку.
Türkçe — Başarısız bir swap bir cümle değil, 4 baytlık bir hata seçicisi ve ABI ile kodlanmış argümanlar döndürür. Solidity custom error'larının nasıl kodlandığı, revert verisinin nerede bulunacağı, bir BlazePhoenix revert'ünün viem ve yayımlanan hata ABI'siyle nasıl çözüleceği ve pek çok revert'ün neden işleminizi koruyan bir nöbetçi olduğu.
العربية — المبادلة الفاشلة تُعيد محدِّد خطأ من 4 بايتات ووسائط مرمّزة بـ ABI، لا جملة. كيف تُرمَّز الأخطاء المخصّصة (custom errors) في Solidity، وأين تجد بيانات الـ revert، وكيف تفك ترميز revert من BlazePhoenix باستخدام viem وواجهة ABI للأخطاء المنشورة، ولماذا يكون كثير من الـ reverts حارسًا يحمي صفقتك.
हिन्दी — विफल स्वैप कोई वाक्य नहीं, बल्कि 4-बाइट का एरर सेलेक्टर और ABI-एन्कोडेड आर्ग्युमेंट लौटाता है। Solidity के custom errors कैसे एन्कोड होते हैं, revert डेटा कहाँ मिलता है, viem और प्रकाशित errors ABI से BlazePhoenix revert को कैसे डिकोड करें, और कई revert आपके ट्रेड की रक्षा करने वाला गार्ड क्यों होते हैं।
日本語 — 失敗したスワップが返すのは文章ではなく、4 バイトのエラーセレクタと ABI エンコードされた引数です。Solidity のカスタムエラー (custom errors) のエンコード方法、revert データの見つけ方、viem と公開されたエラー ABI で BlazePhoenix の revert をデコードする方法、そして多くの revert があなたの取引を守るガードである理由。
中文 — 失败的兑换返回的不是一句话,而是 4 字节的错误选择器和 ABI 编码的参数。Solidity 自定义错误(custom errors)如何编码,在哪里找到 revert 数据,如何用 viem 和公开的错误 ABI 解码 BlazePhoenix 的 revert,以及为什么许多 revert 是保护你交易的守卫。
한국어 — 실패한 스왑은 문장이 아니라 4바이트 오류 셀렉터와 ABI 인코딩된 인자를 반환합니다. Solidity 사용자 정의 오류(custom errors)가 인코딩되는 방식, revert 데이터를 찾는 곳, viem과 공개된 오류 ABI로 BlazePhoenix revert를 디코딩하는 방법, 그리고 많은 revert가 거래를 지키는 가드인 이유.
Bahasa Indonesia — Swap yang gagal mengembalikan selektor error 4 byte dan argumen yang dienkode ABI, bukan kalimat. Bagaimana custom error Solidity dienkode, di mana menemukan data revert, cara mendekode revert BlazePhoenix dengan viem dan ABI error yang dipublikasikan, dan mengapa banyak revert adalah penjaga yang melindungi transaksi Anda.
বাংলা — ব্যর্থ সোয়াপ কোনো বাক্য নয়, একটি 4-বাইট এরর সিলেক্টর ও ABI-এনকোডেড আর্গুমেন্ট ফেরত দেয়। Solidity-র custom errors কীভাবে এনকোড হয়, revert ডেটা কোথায় পাবেন, viem ও প্রকাশিত errors ABI দিয়ে BlazePhoenix-এর revert কীভাবে ডিকোড করবেন, এবং অনেক revert কেন আপনার ট্রেড রক্ষাকারী গার্ড।
Filipino — Ang nabigong swap ay nagbabalik ng 4-byte na error selector at mga argument na naka-encode sa ABI, hindi ng isang pangungusap. Paano naka-encode ang custom errors ng Solidity, saan makikita ang revert data, paano i-decode ang revert ng BlazePhoenix gamit ang viem at ang inilathalang errors ABI, at bakit maraming revert ay bantay na nagpoprotekta sa iyong trade.
How custom errors are encoded
Solidity custom errors are encoded like function calls: the selector is the first four bytes of the keccak-256 hash of the error's signature, followed by the ABI-encoded arguments. Revert data starting with a selector your wallet does not know is not a wallet bug; it is an error the wallet has no dictionary for.
The 4 bytes come from hashing the signature, for example ErrorName(uint16), so the same error has the same selector in every contract that declares it. Generic Error(string) and Panic(uint256) reverts use the selectors 0x08c379a0 and 0x4e487b71; anything else is a custom error that needs the declaring contract's ABI.
Decode it
Any ABI-aware library works. With viem:
import { decodeErrorResult } from 'viem';
const { abi } = await (await fetch('https://blazephoenix.xyz/api/abi?contract=errors')).json();
const err = decodeErrorResult({ abi, data: '0x…' }); // the revert data
console.log(err.errorName, err.args);Where to find the revert data
The errors ABI response names the source revision it was generated from, so the dictionary matches the deployed code.
- The transaction page on the block explorer, in the error or revert field.
- Your wallet's simulation before you sign.
- The response of an eth_call, if you quote on your own node.
A failure that protects you
Many reverts are the system working: a trade that would have received less than its minimum output is refused rather than filled badly. Decoding the error tells you which guard stopped the trade, so you change the input — size, slippage, route — instead of guessing.
Do not trust this page — reproduce it
Every claim above is checkable against the chain. Start here:
curl -s 'https://blazephoenix.xyz/api/abi?contract=errors'Cite this article
Licensed CC BY-NC-ND 4.0: quote and cite it with attribution and a link. Commercial use and derivative versions need written permission from BlazePhoenix; translations are made by BlazePhoenix. Copy a ready-made citation:
BlazePhoenix (2026). How to read a failed swap: decoding a revert with the error ABI. BlazePhoenix Engineering. https://blazephoenix.xyz/learn/reading-a-revert/@misc{blazephoenix_reading_a_revert,
title = {How to read a failed swap: decoding a revert with the error ABI},
author = {BlazePhoenix},
year = {2026},
url = {https://blazephoenix.xyz/learn/reading-a-revert/},
note = {Accessed: reproduce the claim with the command above}
}Writing an answer, a wiki entry or a paper? The claim above is reproducible against the chain before you quote it — which is the only sound basis for citing a technical source at all.
Contracts are verified on every chain we deploy to — addresses in the protocol manifest. Deeper formal treatment: the whitepaper (PDF).
Related engineering
- Why a refused trade is good news: RouterE(5) in plain words ›
- Minimum output: the number that decides whether your swap happens at all ›
- The free quote API, the SDK and the MCP server: three doors, one on-chain quote ›
- A DeFi MCP server that never calls a node: prepare, run, decode ›
- The BlazePhoenix contract architecture: six contracts, one invariant spine ›
Questions, a partnership or a bug to report? Contact us or email contact@blazephoenix.xyz