Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data structure for the REVERT instruction #207

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions EIPS/eip-207.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
eip: 207
title: Data structure for the REVERT instruction
author: Alex Beregszaszi (@axic)
discussions-to:
type: Standards Track
category: ERC
status: Draft
created: 2017-02-06
requires: 140
---

## Simple Summary

Suggested data format for the return value of a `REVERT` instruction.

## Abstract

The `REVERT` instruction is able to abort execution, while retaining data to be returned to the caller. This specification defines a suggested format for encoding error messages to be used by this instruction.

## Motivation

The `REVERT` instruction provides a flexible way to return data. It would be beneficial to define a standardised format in order for clients to make use of this data. Clients, such as Mist, could display the error in a user friendly manner.

Potentially in the future, the *Natural Language Specification* could be extended with a list of error codes for each function.

## Specification

The data to be returned via a `REVERT` instruction is defined as an array, in the following order, consisting of two fields:
- an unsigned number, containing an error code
- an optional UTF-8 encoded string, containing an error message

This array is encoded using *CBOR* (RFC7049).

## Rationale

The reason CBOR is chosen over RLP is its ability to encode multiple data types and the availability of CBOR libraries in a multitude of languages.

## Backwards Compatibility

This change has no effect on contracts created in the past.

## Test Cases

Valid:

`[ 13 ]` -> `81 0d`

`[ 42, "Invalid key"]` -> `82 18 2a 6b 496e76616c6964206b6579`

## Copyright

Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).