From aee4f50d5d6a26c638b67d57f401c6d8a38116fd Mon Sep 17 00:00:00 2001 From: bettybao1209 Date: Thu, 29 Jul 2021 15:14:36 +0800 Subject: [PATCH] NEP: NeoContract Manifest (#114) --- README.mediawiki | 4 +-- nep-15.mediawiki | 94 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 nep-15.mediawiki diff --git a/README.mediawiki b/README.mediawiki index 2694e467..987b26f7 100644 --- a/README.mediawiki +++ b/README.mediawiki @@ -63,11 +63,11 @@ First review [[nep-1.mediawiki|NEP-1]]. Then clone the repository and add your N | Standard | Final |- -| [https://github.com/neo-project/proposals/pull/114 15] +| [[nep-15.mediawiki|15]] | NeoContract Manifest | Erik Zhang, Fernando Díaz Toledano, Vitor Nazário Coelho, Igor Machado Coelho, Li Jianying | Standard -| Accepted +| Final |- | [[nep-16.mediawiki|16]] | NEO Executable Format (NEF) diff --git a/nep-15.mediawiki b/nep-15.mediawiki new file mode 100644 index 00000000..60e4cbd9 --- /dev/null +++ b/nep-15.mediawiki @@ -0,0 +1,94 @@ +
+  NEP: 15
+  Title: NeoContract Manifest
+  Author: Erik Zhang , Fernando Díaz Toledano , Vitor Nazário Coelho , Igor Machado Coelho , Li Jianying  
+  Type: Standard
+  Status: Final
+  Created: 2020-03-20
+  Requires: 14
+
+ +==Abstract== + +A Manifest is a file containing metadata for a group of accompanying files. For example, the files of a computer program may have a manifest describing name, trust information, permissions required for execution. + +This NEP describes the Manifest standards for NEO smart contracts. + +==Motivation== + +There should be a way to expose the access control over the contract. To achieve this, we need a mechanism for describing the features and permissions of smart contracts. With NeoContract Manifest, developers can have clear recognition about the contract and easily create programs to invoke the contract. + +==Rationale== + +We assume the Manifest 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. + +==Specification== + +===Manifest=== + +The NeoContract Manifest 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: + +
+
+{
+  "name": "",
+  "groups": [],
+  "features": {},
+  "supportedstandards": [],
+  "abi": {},
+  "permissions": [],
+  "trusts": [], 
+  "extra": {}
+}
+
+
+ +The name is the name of the contract, which can be any valid identifier. + +The groups field is an array of Group objects which represent a set of mutually trusted contracts. A contract will trust and allow any contract in the same group to invoke it, and the user interface will not give any warnings. + +The features field will be used for future expansion and should always be an empty object for now. + +The supportedstandards field describes the [[obsolete/nep-10.mediawiki|NEP-10]] values. + +The abi field describes which methods and events are included in the contract and how other contracts interact with them. For technical details of ABI, please refer to [https://github.com/neo-project/proposals/pull/119 NEP-14: NeoContract ABI]. + +The permissions field is an array containing a set of Permission objects. It describes which contracts may be invoked and which methods are called. + +The trusts field is an array containing a set of contract hashes or group public keys. It can also be assigned with a wildcard *. If it is a wildcard *, then it means that it trusts any contract. If a contract is trusted, the user interface will not give any warnings when called by the contract. + +The extra field describes the custom user data, such as name, code version, author, description, etc. + +The extension name of the manifest file should be .manifest.json. + +===Group=== + +A Group is identified by a public key and must be accompanied by a signature for the contract hash to prove that the contract is indeed included in the group. + +
+{
+  "pubKey": "0333b24ee50a488caa5deec7e021ff515f57b7993b93b45d7df901e23ee3004916",
+  "signature": "bAhbpx1J8eIPLb5\u002BfvDIRQTbX0doilPxQO\u002BQKS\u002B3fpgyjTwV73UPrv0qsb6I3ZuQjfCA7xoePl5rU508B7k\u002B7w=="
+}
+
+ +Where pubKey represents the public key of the group and signature is the signature of the contract hash encoded in Base64. + +===Permission=== + +The definition of the Permission object is as follows: + +
+{
+  "contract": "hash | group | *",
+  "methods": [] | "*"
+}
+
+ +The contract field indicates the contract to be invoked. It can be a hash of a contract, a public key of a group, or a wildcard *. + +If it specifies a hash of a contract, then the contract will be invoked; If it specifies a public key of a group, then any contract in this group will be invoked; If it specifies a wildcard *, then any contract will be invoked. + +The methods field is an array containing a set of methods to be called. It can also be assigned with a wildcard *, which means that any method can be called. + +If a contract invokes a contract or method that is not declared in the manifest at runtime, the invocation will fail.