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

NEP: NEO Executable Format (NEF) #121

Merged
merged 26 commits into from
Jul 29, 2021
Merged
Changes from 2 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
50 changes: 50 additions & 0 deletions nep-16.mediawiki
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<pre>
NEP: 16
Title: NeoContract NEF
bettybao1209 marked this conversation as resolved.
Show resolved Hide resolved
Author: Fernando Díaz Toledano <shargon@gmail.com>, Erik Zhang <erik@neo.org>, Igor Machado Coelho <igormachado@gmail.com>
bettybao1209 marked this conversation as resolved.
Show resolved Hide resolved
Type: Standard
Status: Accepted
Created: 2020-03-31
</pre>

==Abstract==

A NEF is a file meeting the standard format for a valid NEO executable file. It provides the basic information about the script, including the compiler, version, along with the checksum for data verification.

This NEP describes the NEF standards for NEO smart contracts.
shargon marked this conversation as resolved.
Show resolved Hide resolved

==Motivation==

Although we use neo-vm as the virtual machine currently, we should have other scripts in the future. A standard definition for the executable file format can guarantee both the feasibility of other vm code and the validity of the script file.
erikzhang marked this conversation as resolved.
Show resolved Hide resolved

==Specification==

In the field definitions below, we provide both the definitions of the fields as well as the corresponding functions.

==Fields==

A nef file can be divided into three parts, that is, the file header (Magic, Compiler, Version, ScriptHash), Checksum and Script.

===Magic===

Magic header of the file. It has a constant value of `0x3346454E` in `4` bytes, standing for the NEO Executable Format 3 or NEF3 for short.

===Compiler===

Identifies the compiler used with the length of `32` bytes.
shargon marked this conversation as resolved.
Show resolved Hide resolved

===Version===

Identifies the version of the compiler. It consists of four attributes, namely Mayor, Minor, Build, Revision, with the total size of `16` bytes.
shargon marked this conversation as resolved.
Show resolved Hide resolved

===ScriptHash===

The hash for the script with the length of `20` bytes. It is calculated by using SHA256 and RIPEMD160 algorithm to check the script consistency.
shargon marked this conversation as resolved.
Show resolved Hide resolved

===Checksum===

Used to verify the integrity and accuracy of the file with the length of `4` bytes. When deserializing a nef file, the header will be used to compute the checksum with the Sha256 algorithm. If the result is equal to the checksum field, then we can assert that the file is valid.
shargon marked this conversation as resolved.
Show resolved Hide resolved

===Script===

The script of the payload with the `variable` length.
shargon marked this conversation as resolved.
Show resolved Hide resolved