diff --git a/nep-22.mediawiki b/nep-22.mediawiki new file mode 100644 index 00000000..2b536eca --- /dev/null +++ b/nep-22.mediawiki @@ -0,0 +1,67 @@ +
+  NEP: 22
+  Title: Contract Update Function
+  Author: Owen Zhang , Fernando Díaz Toledano , Erik Zhang , Roman Khimov 
+  Type: Standard
+  Status: Accepted
+  Created: 2021-04-19
+
+ + +==Abstract== + +This proposal outlines a standard for the NEO blockchain that will provide systems with a generalized interaction mechanism for smart contract update. + +==Motivation== + +As the NEO blockchain scales, Smart Contract Update will become increasingly important. We need standize update method in contract to callback native ContractManagement correctly. + +==Specification== + +Neo N3 has a native ContractManagement contract that is used for contract deployment and update via deploy and update methods of it. After settling with the new NEF and manifest both of them will invoke a special _deploy method if it's implemented by the contract. More details in [NEP-29](https://github.com/neo-project/proposals/blob/master/nep-29.mediawiki) + +===Methods=== + +====update==== + +
+{
+  "name": "update",
+  "safe": false,
+  "parameters": [
+    {
+      "name": "nefFile",
+      "type": "ByteArray"
+    },
+    {
+      "name": "manifest",
+      "type": "ByteArray"
+    },
+    {
+      "name": "data",
+      "type": "Any"
+    }
+  ],
+  "returntype": "Void"
+}
+
+ +This method will will callback Update method in native ContractManagement contract. It will update contract state if it's exectued successfully. + +Updating a smart contract MUST have nefFile or manifest.json. If just update one of them at a time is OK, another SHOULD be set as null. It will be passed to _deploy. + +The parameter data can be any type of supported parameters for contract-specific purpose. For example some kinds of json parameters can be put into data for specific check. + +This function SHOULD check whether the signer address equals the owner hash of contract. This function SHOULD use the SYSCALL Neo.Runtime.CheckWitness to verify the signer. Details has been explained in [NEP-30](https://github.com/superboyiii/proposals/blob/upgrade-standard/nep-30.mediawiki). + +===References=== + +https://github.com/neo-project/proposals/blob/master/nep-29.mediawiki + +https://github.com/neo-project/proposals/blob/master/nep-30.mediawiki + +===Implementation=== + +* C#: https://github.com/neo-project/neo-devpack-dotnet/blob/003a50095efe88f63f518a0c989921be086409f3/examples/Example.SmartContract.NEP17/SampleNep17Token.cs#L130 + +* Go: https://github.com/nspcc-dev/neofs-contract/blob/99fb86c35a48ed12017423aa4fee13f7d07fa4c0/contracts/proxy/contract.go#L33