-
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
Invoke contracts' payable method on asset Transfers #108
Comments
Who should throw the exception when return |
This will require all NEP-5 contracts to have dynamic invocation permission. {
"contract": "*",
"methods": ["payable"]
} Is this worth it? |
Good idea @belane, and good point @erikzhang. What about if it only applied to Native NEP-5? These can natively support dynamic invoke. We could have a NEP-Z for Payable (or AlertPayable perhaps), where native NEP-5 is also NEP-Z (AlertPayable), meaning that it will trigger payability condition for other contracts. This way, not all NEP-5 need to be NEP-Z, but if users want to mimic behavior of Native NEP-5, they will be able to. NEP-Z would only specify the Notification format passed to the invoked contract (on |
Agree with @igormcoelho. It shouldn't be included in NEP-5. |
I think it is a worthwhile feature, it brings many possibilities to projects. I only see advantages. The first to implement this functionality should be the native assets, am I right?
|
This is a fundamental feature for Neo 3: the future of blockchain. I don't know the format, but we need it. |
@erikzhang @shargon I think I found an interesting solution for this. Please correct me if I missed some recent development. Suppose we don't make contracts pay for dynamic invoke during deployment, but we make users pay (or not) for it, during invocations (a tiny extra cost). User wallets will likely disable this, unless they need it (as a failed dynamic invoke would cause FAULT if non paid). Now, before invoking the "payable" method on other contract, we execute some Interop that requires Manifest/MethodList and verify that the remote contract actually requires some payable "reaction". Ok, now its easy for wallets: if destination requires payable action, it enables dynamic invoke, otherwise it doesn't (and user saves gas). In any case, this NEP will still be necessary for NEP5 to declare its "willigness" to call remote payable, but I think this resolves the "dynamic invoke dillema". |
Maybe we can add a new SYSCALL: |
Good idea @erikzhang , automatically checks manifest, simplify a lot coding. |
I'm sorry I think |
Makes sense Erik, otherwise it would require some advanced C# "out" abstraction, to express meaning on smart contract. MethodExists is good enough. |
Maybe we can force this syscall if it has a empty return? for this case we need a |
But if this is the case, how do you tell whether the call was successful? |
If it doesn't throw an exception. |
I think system-induced invocations don't have any of these problems. |
If I understood correctly @shargon , a MethodExists is better because its it never throws exception , always boolean. If the call throws, it could be that it was an error in the method itself (but it exists). So you neeed to catch specific exception, like "methodNorFound", but what happens if your call tries to call other method that doesn't exist... will you know that payable method exists but it failed (so you must fail) or you think method doesn't exist and proceed besides the error (that will cause inconsistency on the contract expecting payable method execution)? |
I would love that smart contracts could react to asset transfers, I'm not talking about the
Mint
function, but rather that a smart contract can react, execute, upon receiving NEO or any asset.(remember our old friend
AplicationR
fromNEP7
?)After studying several options we found that the solution is right in front of us.
In Native Contracts (NEO/GAS) we can add a call to the address in if the destination is a contract.
In the
Transfer
method of the native contracts we can include a check of whether the destination account is a contract address, check if it has the payable flag and if so, invoke a specific method of the contract, for examplebool Payable()
Payable
method can be included in theNEP5
standard and must returnTrue
if everything is correct or throw an exception otherwise.In this way smart contracts can react to payments without users having to build a special transaction, invoke
Mint
or whatever.Therefore, Mint invocations won't need a second
APPCALL
, saving network and blockchain resources.It also gives to the contract full management of received payments such as denying money receipts, issuing refunds, etc ...
The text was updated successfully, but these errors were encountered: