-
Notifications
You must be signed in to change notification settings - Fork 113
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
Conversation
…rogrammable-NEP-5-Token-Extension.mediawiki
@deanpress have you considered using Dynamic Invocations instead of 2 separate methods? This will prevent storage from being flooded, because there's no need to temporarily place it in Storage. The |
It's not clear how the dApp contract authenticates the
Obviously NEP-8 needs to be rolled out on the consensus nodes and the contract compiler before dynamic calls like these would be safe to use on the MainNet. |
@jeroenptrs I discussed your suggestion with @brianlenz. The order of invocations in this case could also possibly be turned around by having the user call the dApp contract rather than the NEP-5 contract and utilizing This would require the use of NEP5.1 |
@deanpress it would also mean you need to use |
@jeroenptrs Your suggestion in #64 (comment) would mean the AppCall originates from the NEP5 contract instead of the dApp. From my understanding the flow would be as follows: I agree that this may be a good potential solution as no additional storage from the NEP5 side is necessary, and it's simple. I'm curious as to what the security considerations are other than the requirement of NEP-8 and the contract compiler. |
How to provide these parameters? The entry point for the receiving contract should look like this:
|
It does not look like to be modification of NEP5, which is final btw. This creates unnecessary dependency and both developers (of NEP5 contract and of dApp contract) should be aware and keep this in mind. Here is how we implemented deposit of NEP5 tokens in our Escrow contract:
where addressFrom is user's address and addressTo is ExecutionEngine.ExecutingScriptHash |
@erikzhang for the token, operation will be
Resulting in a call to the |
I updated the NEP to include another feature. The method name is changed to
By letting the user specify @erikzhang the method User/application calls NEP-5 contract with this extension like:
With
@neoescrow It's not meant as a part of NEP-5, but rather an extension applicable to NEP-5 tokens (its own NEP) which can be defined in NEP-10's |
@deanpress okay, but you are trying to put that logic in NEP5 compatible token contract which is out of his scope of responsibility. The NEP5 contract supposed to hold tokens info, isn't? And you propose to continue complicate it for the developer of NEP5 token contract, where he needs to worry about things which can be actually implemented in the dApp contract. |
There is a mix of implementations because the NEP-5 standard implemented exactly as written leaves tokens insecure and crippled for a lot of use cases. So instead of piling on extensions, maybe it's time for a ground-up re-write of the what the official token standard should be and deprecate NEP-5 altogether. |
Agreed with @hal0x2328. If NEP-5 is not only for ICOs but dApps. I have been finding a way how to make a smart contract pass CheckWitness with dynamic calls so users can transfer other tokens that the smart contract owns. Found a solution in MCT document: "The MCT NEP-5 transfer implementation detects that the transfer is coming from an address that corresponds to a known smart contract, and instead of using CheckWitness(scripthash) to verify the owner of the funds, it verifies that the calling contract's scripthash matches the sender's." |
@neoescrow no this is not an addition, this is an extension in the form of a new NEP that's used in tokens, following the NEP-10 standard. There are many tokens that have the - now no longer in the NEP-5 standard (so I don't know how you aim to consider NEP-5 final if such edits can still be made) - optional methods, and there are many that don't. It's important to get new ways of interaction in new standards, or like @hal0x2328 said, scrap NEP-5 all together for a new standard but that won't help either |
The new implementation of smart contract invocations (deployment becomes cheap, GAS fee for invocations) could serve to be a good moment for rewriting NEP-5. If we launch a new NEP-5 standard with all desirable "extensions" and features, it would be a smooth process, and collective deployment fees will not be excessive. Alternatively NEO 3.0 could serve as a decent starting point. But until then, NEP-5 extensions seem to be the way to go because of NEP-10. |
@jeroenptrs it seems, you just read between rows :) The addition or extension doesn't matter. This is a change in NEP5 contract code and the developer should take care of all compatibility cases when he just wants to create NEP5 token, because it costs 490 GAS and you suggest even add 500 more GAS for Dynamic invocation in order to support this standard. Your extension can be implemented in the contract where this functionality is needed - in the dApp contract. |
@neoescrow I feel like you are ignoring everything I stated above. This isn't NEP-5, this is a new standard that builds on top of NEP-5. If you want to develop a NEP-5 token with the functions detailed there, that's a NEP-5 token. If you want further extensibility that this NEP and dynamic invokes provide, you create a token that uses both NEP-5 and this one, also using the addition 1: You, as a dev developing a new token and/or dApp in this smart economy, can just pick and choose standards from which you want to include implemention. If you pick from multiple NEPs surrounding tokens, it would be best to use NEP-10’s specification to detail what standards (including NEP-5 and NEP-10) you are extending. As stated in an earlier comment, there’s already an inconsistency in NEP-5 tokens, because it used to include other methods that were once optional and then removed. To prevent this for future contracts, a standard like NEP-10 has been put into place, so that new functionality can be added to tokens without editing the NEP-5 specific code (as you are currently assuming?). addition 2: this also means that you’re not obligated to pay up another 500 GAS if you’re just developing a NEP-5 token. This has no implication towards existing and future tokens that are set on solely following the NEP-5 standards. The existing tokens that do want this specific implementation in their contract, well then there’s the additional cost of 500 GAS. But this is only in place if you do so choose to use |
@jeroenptrs the things you described are clear, the point of the comments is that it's not a place to put it in the token contract, that's it. Just an opinion, there is no try to be rude ;) |
If I understand it correctly, its function is to notify the receiving contract that a transfer has occurred. Why don't we just call the
Or we can use this way to notify the receiving contract: neo-project/neo#308 |
@erikzhang |
@erikzhang where can I find the |
You can easily combine the And, |
@erikzhang if you invoke the dapp contract separately, how can it verify By |
One way is to automatically call the Another way is to call |
@erikzhang For your For the second example I can see that working, but would have to try in practice. @jeroenptrs what do you think? |
@erikzhang Correct me if I'm wrong, but for the @deanpress we already discussed this, but a fixed operation does make sense in most cases (it would essentially help if You could add a flattened |
@jeroenptrs Adding As for your question to @erikzhang, a smart contract always has to be invoked for it to run an action. So the biggest consideration between |
@deanpress I disagree that dApps that don't work with NEP-5s shouldn't implement an This minimizes coin burn. @erikzhang reading through the GetNotifications proposal, it appears to me this would still require a dynamic invocation because it will only show the notifications from the same invocationtransaction. |
@erikzhang Regarding GetNotifications: If a token allows user input for Notifications, and the receiving smart contract doesn't validate Notifications properly, wouldn't this be more open to vulnerabilities than |
What do you mean by allowing user input? The notification is automatically sent by the token contract. |
@erikzhang could you confirm whether or not To expand on this, as you say here, a user would |
@erikzhang NEP-5 doesn't stop anyone from expanding the smart contract with custom Notification event triggers. Wouldn't it be possible that a different custom Notification event trigger (such as one that allows user input) adds vulnerabilities? I agree with @jeroenptrs, it looks like |
@deanpress Is it still necessary to implement |
This NEP introduces memory-efficient methods for allowing conditional NEP-5 token transactions between users and third party smart contracts without the need for off-chain listeners.
View proposal
Edit:
The latest flow diagram of the method described in the NEP is as below: