Neo Documentation (2024)

Show / Hide Table of Contents

Smart contracts support to be updated or destroyed after release. Before you can do that you need to implement the Update and Destroy interfaces in the old contracts.

Contract Update

In some cases you want to upgrade the smart contracts deployed on the blockchain or migrate the storage of a contract into another new contract, you need to update smart contracts. Neither the contract hash nor the storage is changed when the contract is upgraded.

Implementing the Update interface

To enable the update function, you need to implement the Update method in the contract. In the contract template this method has been implemented by default, as follows:

public static bool Verify() => IsOwner();public static void Update(ByteString nefFile, string manifest){ if (!IsOwner()) throw new Exception("No authorization."); ContractManagement.Update(nefFile, manifest, null);}

If you want to update the contract later, you must implement the update method in the contract prior to deployment. For more information, refer to Deploying and Invoking Smart Contracts .

Updating the contract

  1. Get the compiled NEF file and Manifest file of the new contract ready

  2. Base64-encode the NEF file with the tool like File to Base64 online

  3. Compress and escape the Manifest file with the tool like JSON compressed and escaped online

  4. Use the invoke command to call the update method of the contract

    See Also
    OpenZeppelin

For information about invoking the contract, refer to Invoking contracts .

Neo Documentation (1)

After the update method is executed, the contract is upgraded and neither the contract hash nor the storage area is changed.

Contract Destruction

To destroy a contract, you need to reserve the destruction method in the contract.

To use the contract destroy feature, you need to implement the destroy method in the original contract. The destroy method has been implemented by default in the contract template as follows.

public static bool Verify() => IsOwner();public static void Destroy(){ if (!IsOwner()) throw new Exception("No authorization."); ContractManagement.Destroy();}

The Destroy method takes no arguments. When it is invoked, the contract and its storage, if any, are deleted. Then the contract is no longer available.

Neo Documentation (2024)

FAQs

What is the unit of NEO? ›

The minimum unit of NEO is 1 and tokens cannot be subdivided. GAS is the fuel token for the realization of Neo network resource control, with a maximum total limit of 100 million.

What is the NEO blockchain? ›

The NEO project's blockchain is designed to digitize identities and assets and use smart contracts to track and transfer ownership—a smart economy. NEO originally described its smart economy system as: Digital Assets + Digital Identity + Smart Contract = Smart Economy.

Is NEO proof of stake? ›

Neo is based on the Proof of Stake protocol in combination with delegated Byzantine Fault Tolerance. NEO can be staked by anyone on the network to receive voting power for participation in the network governance that runs on the combination of PoS and dBFT protocols.

Who is the owner of NEO coin? ›

Neo was founded by Da Hongfei and Erik Zhang in 2014 under the name Antshares. The original source code was published to GitHub in July 2015 and the MainNet subsequently launched in October 2016. In 2017, Antshares was rebranded to Neo as it implemented Smart Contracts 2.0.

Top Articles
Latest Posts
Article information

Author: Sen. Ignacio Ratke

Last Updated:

Views: 6555

Rating: 4.6 / 5 (76 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Sen. Ignacio Ratke

Birthday: 1999-05-27

Address: Apt. 171 8116 Bailey Via, Roberthaven, GA 58289

Phone: +2585395768220

Job: Lead Liaison

Hobby: Lockpicking, LARPing, Lego building, Lapidary, Macrame, Book restoration, Bodybuilding

Introduction: My name is Sen. Ignacio Ratke, I am a adventurous, zealous, outstanding, agreeable, precious, excited, gifted person who loves writing and wants to share my knowledge and understanding with you.