Skip to content

Latest commit

 

History

History
94 lines (61 loc) · 4.7 KB

nep-15.mediawiki

File metadata and controls

94 lines (61 loc) · 4.7 KB

  NEP: 15
  Title: NeoContract Manifest
  Author: Erik Zhang <[email protected]>, Fernando Díaz Toledano <[email protected]>, Vitor Nazário Coelho <[email protected]>, Igor Machado Coelho <[email protected]>, Li Jianying <[email protected]> 
  Type: Standard
  Status: Final
  Created: 2020-03-20
  Requires: 14

Table of Contents

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 which standard it supports, such like NEP or RFC. It must be an array. In order to make smart contracts or other clients understand correctly, all NEPs must be capitalized. NEP and number must be connected with -. For example: "supportedstandards": ["NEP-11", "NEP-17", "RFC 1035"].

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 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.