Credence smart contract error codes are explicitly wire-stable. External systems, indexers, and off-chain clients depend on the numeric discriminants of ContractError variants, so those values must never change silently.
- Each
ContractErrorvariant has a fixed numeric code. - Variants must not be renumbered after deployment.
- New variants may only be appended at the end of their existing category block.
- Changing the numeric value of an existing variant is a breaking wire-format change.
- Add the new variant in
contracts/credence_errors/src/lib.rsin the correct category section. - Assign it the next unused code within that category range.
- Add a doc comment describing the variant and reaffirming that the code is wire-stable.
- Add or update tests in
contracts/credence_errors/tests/error_codes_wire.rs. - Run
cargo test -p credence_errors error_codes_wireto verify the discriminant values. - Review the new variant in
docs/errors.mdto keep the canonical reference in sync.
The package includes a dedicated wire-stability assertion test in contracts/credence_errors/tests/error_codes_wire.rs.
If the numeric value of an existing
ContractErrorvariant changes, these assertions must fail.