#Fetching state for proving holding X amount of custom fungible tokens

1 messages · Page 1 of 1 (latest)

pastel summit
#

Hi, how can I query the current state to retrieve the latest proof of an account holding at least X amount of a custom fungible token? My goal is to generate a proof within a zkProgram that verifies whether a user holds more than X amount of a specific custom fungible token. Should I use the Node API for this? Thanks!

spring ginkgo
#

Can you ever trust a proof of blockchain state in a zkProgram? How can you verify that it came from the real Mina?

#

how can I query the current state to retrieve the latest proof of an account holding at least X amount of a custom fungible token
I'm not sure exactly, but it seems like directionally what you mean is a merkle proof for a specific token balances tree? I don't know what tools our nodes have for access to that.

pastel summit
#

It's the concept used in Nori, zk-coprocessors, interop solutions and more

spring ginkgo
spring ginkgo
#

I guess the Mina node graphQL api is pretty obtuse and there's not a good schema explorer for it?

pastel summit
lunar lagoon
# pastel summit That's great, thanks for sharing! What about zkApp's state? Specifically askin...

It is a little bit tricky now as you cannot make a precondition on the circulation account for FungibleToken - it will be blocked by the logic of FungibleToken. You have two options:

  • get the circulation from the FungibleToken method, risking that the circulation will be changed before your tx will be included in the block and the tx will fail
  • track the circulation yourself for your tokens, like in the example where 25% of the tokens holding is required to bid on the auction: https://github.com/minadevelopersalliance/nft-standard/blob/main/src/marketplace/nft-shares.ts#L322
    @wanton ruin probably this problem with precondition on circulation should be fixed in the next version
pastel summit
lunar lagoon
# pastel summit Thanks for the information. I would also like to ask would it be possible to ver...

Theoretically, yes, but you have two issues:

You can, of course, rely on RPC, but RPC can fake the result.

spring ginkgo
# pastel summit That's great, thanks for sharing! What about zkApp's state? Specifically askin...

The snarkedLedgerAccountMemebership proof comes from Mina but you can input a custom token ID. This seems like the right way to prove that a user has X amount of a specific token. Proving ZkApp state is another story though. Can you break down what you need ZkApp state for, vs. what you need ledger data for? I agree with DFST about accessing circulation, but I don't see the relationship between token circulation and a specific account's token balance.

lunar lagoon
pastel summit
# spring ginkgo The snarkedLedgerAccountMemebership proof comes from _Mina_ but you can input a ...

Yes, as you mentioned, I asked about two different cases:

1- Obtaining proof of an account's state for a custom fungible token.
2- Obtaining proof of an account's state for native tokens.

Both cases are for generating a client-side proof to verify whether a user's balance is greater than X.

That's why I wanted to ask if it's possible to use the proof fetched from the snarked ledger or in a zkProgram. The same question for the state of the custom fungible token as well.

sacred star
#

I mean both are much simpler to do with a balance precondition, if you end up settling your proof to Mina