Skip to content

Commit

Permalink
nep-26/27: clarify failure mode for unimplemented onNEPXXPayment
Browse files Browse the repository at this point in the history
Add a bit more details, signify the need for script hash check.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
  • Loading branch information
roman-khimov committed May 29, 2024
1 parent e2e107c commit f672f50
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
16 changes: 10 additions & 6 deletions nep-26.mediawiki
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,16 @@ MUST implement <code>onNEP11Payment</code> method with the following signature:
</pre>

A contract that doesn't implement this method will not be able to receive
[[nep-11.mediawiki|NEP-11]] tokens (transfers to its address will fail). This
method is called by [[nep-11.mediawiki|NEP-11]] contracts which tokens are being
transferred. A particular token can be obtained via the <code>System.Runtime.GetCallingScriptHash</code>
system call. Contracts SHOULD check for this hash to match their expectations
like allowed/accepted tokens, processing this call means that contract trusts
the caller to implement [[nep-11.mediawiki|NEP-11]] correctly.
[[nep-11.mediawiki|NEP-11]] tokens (standard requires this method to be called
unconditionally which will fail at the system call level if it's not implemented
which then leads to a complete transaction failure). This method is called by
[[nep-11.mediawiki|NEP-11]] contracts which tokens are being transferred. A
particular token can be obtained via the <code>System.Runtime.GetCallingScriptHash</code>
system call. Notice that technically this method MAY be called by entry scripts or
non-[[nep-11.mediawiki|NEP-11]] contracts as well, so contracts SHOULD check for
caller script hash to match their expectations like allowed/accepted tokens.
Processing this call means that contract trusts the caller to implement
[[nep-11.mediawiki|NEP-11]] correctly.

<code>from</code> parameter specifies the sender of tokens and can be <code>null</code>
for minted tokens.
Expand Down
16 changes: 10 additions & 6 deletions nep-27.mediawiki
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,16 @@ MUST implement <code>onNEP17Payment</code> method with the following signature:
</pre>

A contract that doesn't implement this method will not be able to receive
[[nep-17.mediawiki|NEP-17]] tokens (transfers to its address will fail). This
method is called by [[nep-17.mediawiki|NEP-17]] contracts which tokens are being
transferred. A particular token can be obtained via the <code>System.Runtime.GetCallingScriptHash</code>
system call. Contracts SHOULD check for this hash to match their expectations
like allowed/accepted tokens, processing this call means that contract trusts
the caller to implement [[nep-17.mediawiki|NEP-17]] correctly.
[[nep-17.mediawiki|NEP-17]] tokens standard requires this method to be called
unconditionally which will fail at the system call level if it's not implemented
which then leads to a complete transaction failure). This method is called by
[[nep-17.mediawiki|NEP-17]] contracts which tokens are being transferred. A
particular token can be obtained via the <code>System.Runtime.GetCallingScriptHash</code>
system call. Notice that technically this method MAY be called by entry scripts or
non-[[nep-17.mediawiki|NEP-17]] contracts as well, so contracts SHOULD check for
caller script hash to match their expectations like allowed/accepted tokens.
Processing this call means that contract trusts the caller to implement
[[nep-17.mediawiki|NEP-17]] correctly.

<code>from</code> parameter specifies the sender of tokens and can be <code>null</code>
for minted tokens.
Expand Down

0 comments on commit f672f50

Please sign in to comment.