Is there an example of how to use permission policies and hook permission behaviour with regards to FA2 implementation? https://gitlab.com/tzip/tzip/-/blob/master/proposals/tzip-12/tzip-12.md I am having a hard time wrapping my head around this idea. Does hook require a secondary contract for it to execute? Is there a standard for me to use approvals like in FA1.2 where we can state the amount to transfer instead of giving operator permissions in FA2?
- If you choose a permission policy that supports sender/receiver hooks, token owner contracts (addresses that hold token balances) should implement corresponding entry points (
%tokens_received). Those entry points will be called by the FA2 contract during transfer. There is an example of a simple receiver hook: https://gitlab.com/tzip/tzip/-/blob/fa2-editing/proposals/tzip-12/examples/fa2_custom_receiver.mligo
There is also an example of the FA2 implementation that supports sender/receiver hooks and usage of the receiver hook: https://github.com/tqtezos/smart-contracts/tree/master/fa2_hooks
- Instead of FA1.2 allowances, FA2 uses operators. Operators can transfer ANY token and ANY amount on behalf of the token owner. We analyzed the actual usage of the allowances for both ERC-20 and FA1.2 and found that virtually nobody use them for the granular control. The most frequent use case is to give maximum allowance to the trusted address (operator). ERC-1155 standard also specifies operators instead of allowances.
Although it is possible to create allowance wrapper contract for the FA2 or extend FA2 with the custom permission policy to support allowances.