{"action":"created","issue":{"url":"https://api.github.com/repos/ethereum/EIPs/issues/838","repository_url":"https://api.github.com/repos/ethereum/EIPs","labels_url":"https://api.github.com/repos/ethereum/EIPs/issues/838/labels{/name}","comments_url":"https://api.github.com/repos/ethereum/EIPs/issues/838/comments","events_url":"https://api.github.com/repos/ethereum/EIPs/issues/838/events","html_url":"https://github.com/ethereum/EIPs/issues/838","id":290197730,"number":838,"title":"EIP 838: ABI specification for REVERT reason string","user":{"login":"federicobond","id":138426,"avatar_url":"https://avatars1.githubusercontent.com/u/138426?v=4","gravatar_id":"","url":"https://api.github.com/users/federicobond","html_url":"https://github.com/federicobond","followers_url":"https://api.github.com/users/federicobond/followers","following_url":"https://api.github.com/users/federicobond/following{/other_user}","gists_url":"https://api.github.com/users/federicobond/gists{/gist_id}","starred_url":"https://api.github.com/users/federicobond/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/federicobond/subscriptions","organizations_url":"https://api.github.com/users/federicobond/orgs","repos_url":"https://api.github.com/users/federicobond/repos","events_url":"https://api.github.com/users/federicobond/events{/privacy}","received_events_url":"https://api.github.com/users/federicobond/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2018-01-20T14:53:48Z","updated_at":"2018-04-06T13:04:23Z","closed_at":null,"author_association":"NONE","body":"    EIP: 838\r\n    Title: ABI specification for REVERT reason string\r\n    Author: Federico Bond\r\n    Status: Draft\r\n    Created: 2017-01-20\r\n\r\n\r\n## Simple Summary\r\n\r\nA proposal to extend the ABI specification to include typed errors in the REVERT reason string.\r\n\r\n## Abstract\r\n\r\nThis proposal specifies how to encode potential error conditions in the JSON ABI of a smart contract. A high-level language could then provide a syntax for declaring and throwing these errors. The compiler will encode these errors in the `reason` parameter of the `REVERT` opcode in a way that can be easily reconstructed by libraries such as web3.\r\n\r\n## Motivation\r\n\r\nIt's important to provide clear feedback to users (and developers) about what went wrong with their Ethereum transactions. The `REVERT` opcode is a step in the right direction, as it allows smart contract developers to encode a message describing the failure in the reason parameter. There is an [implementation](1) under review in Solidity that accepts a string, thus providing a low-level interface to this parameter. However, standardizing a method for passing errors from this parameter back to clients will bring many benefits to both users and developers.\r\n\r\nThe key words \"MUST\", \"MUST NOT\", \"REQUIRED\", \"SHALL\", \"SHALL NOT\", \"SHOULD\", \"SHOULD NOT\", \"RECOMMENDED\",  \"MAY\", and \"OPTIONAL\" in this document are to be interpreted as described in RFC 2119.\r\n\r\n## Specification\r\n\r\nTo conform to this specification, compilers producing JSON ABIs SHOULD include error declarations alongside functions and events. Each error object MUST contain the keys `name` (string) and `arguments` (same types as the function’s `inputs` list). The value of `type` MUST be \"error\".\r\n\r\nExample:\r\n```\r\n{ \"type\": \"error\", \"name\": \"InsufficientBalance\", \"arguments\": [ { \"name\": \"amount\", \"type\": \"uint256\" } ] }\r\n```\r\n\r\nA selector for this error can be computed from its signature (`InsufficientBalance()` for the example above) in the same way that it's currently done for public functions and events. This selector MUST be included in the reason string so that clients can perform a lookup. Any arguments for the error are [RLP](https://github.com/ethereum/wiki/wiki/RLP) encoded in the same way as return values from functions. The exact format in which both the selector and the arguments are encoded is to be defined. The Solidity implementation mentioned above leaves room for expansion by prefixing the free-form string with `uint256(0)`.\r\n\r\nA high-level language like Solidity can then implement a syntax like this:\r\n\r\n```\r\ncontract MyToken {\r\n  error InsufficientFunds(uint256 amount);\r\n\r\n  function transfer(address _to, uint256 _amount) {\r\n    if (balances[msg.sender] <= _amount)\r\n       throw InsufficientFunds(_amount);\r\n    ...\r\n  }\r\n  ...\r\n}\r\n```\r\n\r\n## Possible extensions\r\n\r\n1. A [NatSpec](https://github.com/ethereum/wiki/wiki/Ethereum-Natural-Specification-Format) comment above the error declaration can be used to provide a default error message. Arguments to the error can be interpolated in the message string with familiar NatSpec syntax.\r\n\r\n```\r\n/// @notice You don't have enough funds to transfer `amount`.\r\nerror InsufficientFunds(uint256 amount);\r\n```\r\n\r\n2. A function may declare to its callers which errors it can throw. A list of these errors must be included in the JSON ABI item for that function, under the `errors` key. Example:\r\n\r\n```\r\nfunction transfer(address _to, uint256 _amount) throws(InsufficientFunds);\r\n```\r\n\r\nSpecial consideration should be given to error overloading if we want to support a similar syntax in the future, as errors with same name but different arguments will produce a different selector.\r\n\r\n## Backwards Compatibility\r\n\r\nApps and tools that have not implemented this spec can ignore the encoded reason string when it's not prefixed by zero.\r\n\r\n## Revisions\r\n\r\n * 2018/01/23: Improved writing and clarified summary\r\n * 2018/01/10: Initial draft\r\n\r\n## Copyright\r\n\r\nCopyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).\r\n\r\n[1]: https://github.com/ethereum/solidity/pull/3364"},"comment":{"url":"https://api.github.com/repos/ethereum/EIPs/issues/comments/379246827","html_url":"https://github.com/ethereum/EIPs/issues/838#issuecomment-379246827","issue_url":"https://api.github.com/repos/ethereum/EIPs/issues/838","id":379246827,"user":{"login":"Arachnid","id":17865,"avatar_url":"https://avatars2.githubusercontent.com/u/17865?v=4","gravatar_id":"","url":"https://api.github.com/users/Arachnid","html_url":"https://github.com/Arachnid","followers_url":"https://api.github.com/users/Arachnid/followers","following_url":"https://api.github.com/users/Arachnid/following{/other_user}","gists_url":"https://api.github.com/users/Arachnid/gists{/gist_id}","starred_url":"https://api.github.com/users/Arachnid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Arachnid/subscriptions","organizations_url":"https://api.github.com/users/Arachnid/orgs","repos_url":"https://api.github.com/users/Arachnid/repos","events_url":"https://api.github.com/users/Arachnid/events{/privacy}","received_events_url":"https://api.github.com/users/Arachnid/received_events","type":"User","site_admin":false},"created_at":"2018-04-06T13:04:23Z","updated_at":"2018-04-06T13:04:23Z","author_association":"COLLABORATOR","body":"I'm suggesting that having an error selector in general is needless."}}
{"actor":{"display_login":"Arachnid"}}