Skip to main content
Version: v1.3

The errors Contract

The errors contract is one of the core contracts on each IOTA Smart Contracts chain.

The errors contract keeps a map of error codes to error message templates. This allows contracts to store lengthy error strings only once and then reuse them by just providing the error code (and optional extra values) when producing an error, thus saving storage and gas.

Entry Points

registerError(m ErrorMessageFormat) c ErrorCode

Registers an error message template.


  • m (string): The error message template, which supports standard go verbs for variable printing.


  • c (ErrorCode): The error code of the registered template


getErrorMessageFormat(c ErrorCode) m ErrorMessageFormat

Returns the message template stored for a given error code.


  • c (ErrorCode): The error code of the registered template.


  • m (string): The error message template.



ErrorCode is encoded as the concatenation of:

  • The contract hname(hname).
  • The error ID, calculated as the hash of the error template(uint16).


UnresolvedVMError is encoded as the concatenation of:

  • The error code (ErrorCode).
  • CRC32 checksum of the formatted string (uint32).
  • The JSON-encoded list of parameters for the template (string prefixed with uint16 size).