diff --git a/nep-19.mediawiki b/nep-19.mediawiki new file mode 100644 index 00000000..30c5f027 --- /dev/null +++ b/nep-19.mediawiki @@ -0,0 +1,101 @@ +
+ NEP: + Title: Contract Basic Methods Guideline + Author: Owen Zhang+ + + + + + +==Abstract== + +This proposal outlines a basic method guideline for the NEO blockchain that will provide systems with a generalized interaction mechanism for smart contract initial deploy, update and destroy. + +==Motivation== + +As the NEO blockchain scales, Smart Contract Initial Deploy, Update and Destroy will become increasingly important. Without guideline for, Fernando Díaz Toledano , Erik Zhang + Type: Informational + Status: Draft + Created: 2021-04-19 + Replaces: 0 +
_deploy
, update
and destroy
method, systems will be required to maintain a unique API for each contract, regardless of their similarity to other contracts which makes application development very inconvenient. This guideline can lead most contracts to implement the same basic methods with the same types of parameters but still accept diversity.
+
+==Specification==
+
+In the method definitions below, we provide both the definitions of the functions as they are defined in the contract as well as the invoke parameters.
+
+===Methods===
+
+====_deploy====
+
++{ + "name": "_deploy", + "safe": false, + "parameters": [ + { + "name": "data", + "type": "Any" + }, + { + "name": "update", + "type": "Boolean" + } + ], + "returntype": "Void" +} ++ +This is an optional function which will be automatically executed when contract first deployed. + +The parameter
data
can be any type of supported parameters for additional message purpose.
+
+update
returns if it's the initial deployment of this contract. The function SHOULD check whether update
returns true. If not, continue execution. If true, return.
+
+====update====
+
++{ + "name": "update", + "safe": false, + "parameters": [ + { + "name": "nefFile", + "type": "ByteArray" + }, + { + "name": "manifest", + "type": "String" + }, + { + "name": "data", + "type": "Any" + } + ], + "returntype": "Void" +} ++ +Updating a smart contract MUST have
nefFile
and manifest.json
.
+
+The parameter data
can be any type of supported parameters for additional message purpose.
+
+The function SHOULD check whether the signer
address equals the owner
hash of contract. The function SHOULD use the SYSCALL Neo.Runtime.CheckWitness
to verify the signer
.
+
+====destroy====
+
++{ + "name": "destroy", + "safe": false, + "parameters": [], + "returntype": "Void" +} ++This function can delete all the storage of this contract. + +The function SHOULD check whether the
signer
address equals the owner
hash of contract. The function SHOULD use the SYSCALL Neo.Runtime.CheckWitness
to verify the signer
.
+
+If any token is in this contract asset, they MUST be transferred to another address before destroy
.
+