#ERC20 Approve/Allowance Functions

1 messages · Page 1 of 1 (latest)

bold mango
#

Could anyone guide me on how to implement ERC20-equivalent allowances functions on Mina? Should I use Events or Merkle Trees for this purpose?

I understand that we can fetch events from archive nodes, however, I am not sure how to filter these events to retrieve specific info (e.g. the allowance of a specified owner-spender pair). Similarly, I am struggling to understand the concept of Merkle witnesses, and how to extract info from a Merkle Tree. For example, if the Merkle Tree stores a mapping of owner-spender-allowance, how can I use specified owner and spender addresses to extract the allowance value?

north hatch
#

My quick reaction is, why do you need allowances? I think they are a weird design that came about because Ethereum didn't have custom tokens built in, but Mina has, and I claim allowances don't give you anything on Mina if you're using built in tokens

bold mango
north hatch
#

One approach to implement an allowance would be to store them on the user token account, by making that account a zkApp, that has a method spend() which decides who can spend from the account.
You could store the allowances given by that specific account either as actions or Merkle tree. That's only a high level idea though