Revert
use fuel_types::ContractId;
pub struct Revert {
pub contract_id: ContractId,
pub error_val: u64,
}
- A
Revertreceipt is produced when a Sway smart contract function call fails. - The table below lists possible reasons for the failure and their values.
- The
error_valfield records these values, enabling your indexer to identify the specific cause of the reversion.
| Reason | Value |
|---|---|
| FailedRequire | 0 |
| FailedTransferToAddress | 1 |
| FailedSendMessage | 2 |
| FailedAssertEq | 3 |
| FailedAssert | 4 |
You can handle functions that could produce a Revert receipt by adding a parameter with the type abi::Revert.
fn handle_revert(revert: abi::Revert) {
// handle the revert
}