-
Notifications
You must be signed in to change notification settings - Fork 115
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
NEP: NeoContract ABI #12
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f4cbabe
draft
f89269c
fix spelling
14438b7
update status for accepting NEP-3
c5df0bd
add recommended entry point
748db75
Update nep-3.mediawiki
c7441ba
Merge branch 'master' into NeoContractABI
f01bf49
change state to final
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
<pre> | ||
NEP: <to be assigned> | ||
Title: NeoContract ABI | ||
Author: Erik Zhang <[email protected]> | ||
Type: Standard | ||
Status: Draft | ||
Created: 2017-09-13 | ||
</pre> | ||
|
||
==Abstract== | ||
|
||
An Application Binary Interface (ABI) is the interface between two program modules, one of which is often a library and/or operating system and the other one is usually an application created by a regular programmer. | ||
|
||
This NEP describes the ABI standards for NEO smart contracts. | ||
|
||
==Motivation== | ||
|
||
NEO smart contract system is designed to be mutually invocable between contracts. To achieve this, we need a mechanism for exposing the interface of smart contracts. With NeoContract ABI, developers can easily create programs to invoke smart contracts or write clients that automatically access contract functionalities. | ||
|
||
==Rationale== | ||
|
||
We assume the Application Binary Interface (ABI) is strongly typed, known at compilation time and static. No introspection mechanism will be provided. We assert that all contracts will have the interface definitions of any contracts they call available at compile-time. | ||
|
||
This specification does not address contracts whose interface is dynamic or otherwise known only at run-time. Should these cases become important they can be adequately handled as facilities built within the NEO ecosystem. | ||
|
||
==Specification== | ||
|
||
===Contract=== | ||
|
||
The NeoContract ABI is defined by JSON format, which has the following basic structure, where some of the top-level objects can have any number of child objects: | ||
|
||
<pre> | ||
{ | ||
"hash": "0x562851057d8afbc08fabc8c438d7cc771aef2195", | ||
"entrypoint": "main", | ||
"functions": [], | ||
"events": [] | ||
} | ||
</pre> | ||
|
||
<code>hash</code> is the script hash of the contract. It is encoded as a hexadecimal string in big-endian. | ||
|
||
<code>entrypoint</code> indicates that which is the entry point of the contract in <code>functions</code>. | ||
|
||
<code>functions</code> is an array of Function objects which describe the details of each function in the contract. | ||
|
||
<code>events</code> is an array of Event objects which describe the details of each event in the contract. | ||
|
||
===Function=== | ||
|
||
Function object has the following structure: | ||
|
||
<pre> | ||
{ | ||
"name": "transfer", | ||
"parameters": [], | ||
"returntype": "Boolean" | ||
} | ||
</pre> | ||
|
||
<code>name</code> is the name of the function, which can be any valid identifier. | ||
|
||
<code>parameters</code> is an array of Parameter objects which describe the details of each parameter in the function. | ||
|
||
<code>returntype</code> indicates the return type of the function. It can be one of the following values: <code>Signature</code>, <code>Boolean</code>, <code>Integer</code>, <code>Hash160</code>, <code>Hash256</code>, <code>ByteArray</code>, <code>PublicKey</code>, <code>String</code>, <code>Array</code>, <code>InteropInterface</code>, <code>Void</code>. | ||
|
||
===Event=== | ||
|
||
Event object has the following structure: | ||
|
||
<pre> | ||
{ | ||
"name": "refund", | ||
"parameters": [] | ||
} | ||
</pre> | ||
|
||
<code>name</code> is the name of the event, which can be any valid identifier. | ||
|
||
<code>parameters</code> is an array of Parameter objects which describe the details of each parameter in the event. | ||
|
||
===Parameter=== | ||
|
||
Parameter object has the following structure: | ||
|
||
<pre> | ||
{ | ||
"name": "from", | ||
"type": "Hash160" | ||
} | ||
</pre> | ||
|
||
<code>name</code> is the name of the parameter, which can be any valid identifier. | ||
|
||
<code>type</code> indicates the type of the parameter. It can be one of the following values: <code>Signature</code>, <code>Boolean</code>, <code>Integer</code>, <code>Hash160</code>, <code>Hash256</code>, <code>ByteArray</code>, <code>PublicKey</code>, <code>String</code>, <code>Array</code>, <code>InteropInterface</code>. | ||
|
||
===ParameterType=== | ||
|
||
ParameterType enum has the following values: | ||
|
||
{| | ||
!name | ||
!description | ||
|- | ||
| Signature | ||
| A signature of a transaction or block which is generated by the user. | ||
|- | ||
| Boolean | ||
| A boolean value can be either <code>true</code> or <code>false</code>. | ||
|- | ||
| Integer | ||
| An arbitrarily large integer whose value in theory has no upper or lower bounds. | ||
|- | ||
| Hash160 | ||
| A 160-bits integer. | ||
|- | ||
| Hash256 | ||
| A 256-bits integer. | ||
|- | ||
| ByteArray | ||
| A byte array. | ||
|- | ||
| PublicKey | ||
| An ECC public key which is encoded with compressed mode. | ||
|- | ||
| String | ||
| A string which is encoded in UTF-8. | ||
|- | ||
| Array | ||
| An array of objects. | ||
|- | ||
| InteropInterface | ||
| An interface which is returned by interop services. | ||
|- | ||
| Void | ||
| Void means that the function has no return value. This value cannot be the type of a parameter. | ||
|} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about changing:
To:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course I meant "compile-time", I updated my comment...