Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destroy standard #182

Merged
merged 23 commits into from
Jan 11, 2025
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions nep-X1.mediawiki
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<pre>
NEP: 31
Title: Contract Destroy Function
Author: Owen Zhang <zhangzhihong@ngd.neo.org>
Type: Standard
Status: Draft
Created: 2024-09-11
</pre>

==Abstract==

This proposal standardizes the destroy function which is necessary for contract storage deletion.

==Motivation==

N3 already provided contract destroy mechanism but it hasn't been summarized in a standard. This standard will show details.

==Specification==

Neo N3 has a native <code>ContractManagement</code> contract that is used for contract destroy via <code>destroy</code> method. When <code>destroy</code> is executed, it will callback the <code>destroy</code> method in <code>ContractManagement</code>. Finally, it will delete all storage and entries of this contract. It will block the contract address in native <code>Policy</code> contract as well.

===Methods===

====destroy====

<pre>
{
"name": "destroy",
"safe": false,
"parameters": [],
"returntype": "Void"
}
</pre>
This method will automatically invoke <code>destroy</code> method of <code>ContractManagement</code> contract when a contract is destroyed.

===Events===

====Destroy====

<pre>
{
"name": "Destroy",
"parameters": [
{
"name": "contract",
"type": "Hash160"
}
]
}
</pre>

<code>Destroy</code>notification will be emitted automatically by native <code>ContractManagement</code> contract as well. It will notify contract hash in event.

==References==


==Implementation==

* C#: https://github.com/neo-project/neo-devpack-dotnet/blob/003a50095efe88f63f518a0c989921be086409f3/examples/Example.SmartContract.NFT/Loot.Admin.cs#L79