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

NEP: Programmable NEP-5 Token Extension #64

Closed
wants to merge 29 commits into from
Closed
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0bc043a
Create NEP-Programmable-Token-Extension.mediawiki
deanpress Aug 9, 2018
ba3b3ce
Update and rename NEP-Programmable-Token-Extension.mediawiki to NEP-P…
deanpress Aug 9, 2018
e8d491b
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 9, 2018
9936ed7
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 9, 2018
c72efa5
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 9, 2018
2b9b24f
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 9, 2018
6602d64
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 9, 2018
5b20e51
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 9, 2018
2d51ff4
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 9, 2018
8285b48
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 9, 2018
c072416
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 9, 2018
ed7a709
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 9, 2018
5ddacdc
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 10, 2018
554f5c4
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 10, 2018
02d6740
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 10, 2018
ea1d996
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 10, 2018
90c0369
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 10, 2018
d9d35b7
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 10, 2018
61a261a
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 10, 2018
421107a
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 10, 2018
e8387ca
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 10, 2018
5ea100c
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 10, 2018
7820d31
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 10, 2018
dd0c5be
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 10, 2018
975a44d
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 10, 2018
e015040
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 10, 2018
c32b283
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 10, 2018
47c37c2
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 10, 2018
2e64786
Update NEP-Programmable-NEP-5-Token-Extension.mediawiki
deanpress Aug 10, 2018
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
68 changes: 68 additions & 0 deletions NEP-Programmable-NEP-5-Token-Extension.mediawiki
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<pre>
NEP: <to be assigned>
Title: Programmable NEP-5 Token Extension
Authors: Dean van Dugteren (dean@nos.io), Jeroen Peeters (contact@jeroenpeeters.me)
Type: Standard
Status: Draft
Created: 2018-08-09
Revisision: 2018/08/10
Requires: NEP-5
</pre>

===NOTE: To be updated===

==Abstract==

This NEP introduces a memory-efficient method for allowing conditional NEP-5 token transactions between users and third party smart contracts without the need for off-chain listeners. The methods take into account future changes in invocation fees, so as to make it work efficiently in multiple scenarios.

==Motivation==
All tokens should be ''programmable''. By programmable we mean that tokens should be conditionally transacted and held between users and smart contracts alike.

Presently, dApp smart contracts handle conditional transactions (e.g. staking a NEP5 token with a release condition) via off-chain listeners that send invocations based on certain triggers such as NEP5 Transaction Notification events.

This NEP proposes the following solution:


* A separate transfer method and operation <code>transferAndInvoke(from, to, amount, scriptHash, operation, args)</code> that makes a transaction of NEP5 tokens using <code>from, to, amount</code> and calls a dynamic invocation on the <code>scriptHash</code> script hash, using <code>(string) from, (string) to, (bigint) amount, (string) operation, (list) args</code> in the arguments list to be used in the dynamic invocation.

The ''transferAndInvoke'' operation can be called by web-based applications integrating with ''neon-js'', nOS dApps, and applications utilizing NeoLink or the NEX plug-in. Additionally, wallet applications such as ''Neon Wallet'' can present the user with an option whether their transaction is intended for a user or a smart contract (effectively switching between ''transfer'' and ''transferAndInvoke'' operations).

One of the use cases is that an ICO smart contract can listen to transactions made to a different address, since the target receiver <code>to</code> and target smart contract <code>scriptHash</code> can differ.
Use cases also include token staking, conditional token releases, and anything else that a smart contract can do with ''programmable tokens''.

To achieve this, the NEP-5 token will need to be able to make dynamic invocations.

==Specification==

We propose the following methods to be implemented in any token contract that is looking to have a memory-efficient ''programmable'' NEP5 token:

[[File:https://user-images.githubusercontent.com/31391056/43956007-d3125fbe-9ca2-11e8-8e31-757a6768ad04.png]]

===Methods===

====transferAndInvoke====

* Syntax: <code>public static bool transferAndInvoke(from, to, amount, scriptHash, operation, args)</code>

* Remarks:
** This method (with operation ''transferAndInvoke'') executes the NEP5 token's <code>transfer(from, to, amount)</code> function, and dynamically invokes the script hash derived from the <code>scriptHash</code> parameter, providing <code>from, to, amount, scriptHash, operation, args</code> as parameters for the receiving smart contract.



==Example==
User/application calls NEP-5 contract with this extension like:
transferAndInvoke [ myAddress, yourAddress, 100, dAppContractScriptHash, "processTransaction", ["This is a string to be handled by the dApp smart contract", "another string", 10, "as many as you want"] ]


With `transferAndInvoke`, the NEP5 contract makes a dynamic invocation to `dAppContractScriptHash` with operation <code>processTransactions</code> and an args list:

args[0] : from
args[1] : to
args[2] : amount
args[3] : "This is a string to be handled by the dApp smart contract"
args[4] : "another string"
args[5] : 10
args[6] : "as many as you want"

==Implementation==
TBD