I was trying to implement a balance_of function. According to the documentation, it should be looking like this

          "requests": [ $requests_item, … ],
          "callback": contract ($callback_param)

        list (pair (pair %request (address %owner) (nat %token_id)) (nat %balance))

          "owner": address,
          "token_id": nat

While Implementing i got stuck at the "callback": contract ($callback_param) because I cant figure out, what I have to place there. Currently I have this:


        "requests": [{
            "owner": 'tzxxxxxxxxxxxxx',
            "token_id": 0


What exactly do I have to fill in there?


1 Answer 1


This is not the answer that you're expecting, but I guess you should still give it a read.

The balance_of entrypoint is a view entrypoint as described in this Deprecated TZIP So, it is mostly used when you want to fetch someone's balance from another contract. In that case, your contract will call this balance_of entrypoint of the token contract, and the token contract will call back to your contract's callback entrypoint with the balance value.

Here is an example, taken from SmartPy legacy docs enter image description here

If you want to fetch balances off-chain. You can use indexers like TzKt Token API or off-chain views. FA2 contracts can have a get_balance off-chain view, as described in TZIP-12.

Note: If you're using off-chain views make sure that it is present in the contract. You can check that by going to the VIEWS tab of better call dev.

  • It should not be considered an onchain view anymore as there is now a separate concept for onchain views. Can you fix your message?
    – Jordan_tez
    Commented May 11, 2023 at 7:54
  • 1
    Thanks for the suggestion :) I've updated it. Commented May 11, 2023 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.