Skip to content

Latest commit

 

History

History
71 lines (49 loc) · 3.2 KB

nep-22.mediawiki

File metadata and controls

71 lines (49 loc) · 3.2 KB

  NEP: 22
  Title: Contract Update Function
  Author: Owen Zhang <[email protected]>, Fernando Díaz Toledano <[email protected]>, Erik Zhang <[email protected]>, Roman Khimov <[email protected]>
  Type: Standard
  Status: Accepted
  Created: 2021-04-19

Table of Contents

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 a standard for update method in contract to callback native ContractManagement correctly.

Specification

All contracts SHOULD implement this NEP to be able to fix bugs or otherwise improve functionality. If no update method there, incorrect action can never be corrected.

Methods

update

{
  "name": "update",
  "safe": false,
  "parameters": [
    {
      "name": "nefFile",
      "type": "ByteArray"
    },
    {
      "name": "manifest",
      "type": "ByteArray"
    },
    {
      "name": "data",
      "type": "Any"
    }
  ],
  "returntype": "Void"
}

This method MUST call update method in native ContractManagement contract. It will update contract state if it's executed successfully.

Calls to this method MUST have nefFile or manifest. These are serialized representations of NEF (NEP-16 and NeoContract manifest (NEP-15). Omitting one of them (setting to null) is a valid call, this means no changes to this component (old version is kept). These two parameters MUST be passed into ContractManagement's update method.

The parameter data can be any type of supported parameters for contract-specific purpose. For example some kinds of parameters can be put into data for specific check. See NEP-29 for additional reference on contract update callback mechanism that works with this parameter.

This method SHOULD do Checkwitness for contract owner to avoid security risks. This function SHOULD use the SYSCALL Neo.Runtime.CheckWitness to verify the signer.

It's strongly recommended to execute all codes before calling ContractManagement's update method to ensure they can be executed correctly.

References

https://github.com/neo-project/proposals/blob/master/nep-15.mediawiki

https://github.com/neo-project/proposals/blob/master/nep-16.mediawiki

https://github.com/neo-project/proposals/blob/master/nep-29.mediawiki

Implementation