1

In Michelson, is it possible to get the balance of a contract other than the current one?

According to the Michelson reference, it's possible for a contract to get its own balance. But, is it possible to get the balance of an arbitrary contract? E.g., is there a function get_balance : address -> tez somewhere?

Thanks!

2 Answers 2

0

No, it’s not possible in full generality.

2
  • Do you know if there's a good reason for this? It seems like a missing feature, and one that I would use if it were available. Nov 14, 2021 at 18:09
  • @emchristiansen, there’s a principle of not exposing unnecessary blockchain features (I’m not saying that I agree that checking balance is unnecessary) and I guess this is the main driver. Also, please note that during transactions, the notion of contract balances in Tezos is not that easy to grasp. In particular, you may feel or not that it is synchronized with the storage. (This point comes from the fact that operations are created and then executed. Still so much better than it used to be in the early days with BFS).
    – FFF
    Nov 14, 2021 at 20:49
0

The only balance that a smart contract can read is its own but:

  • any smart contract can expose its balance in a view,
  • the voting power of any implicit account can be obtained by the VOTING_POWER instruction, this differs from the balance in that it is expressed in rolls and it also includes delegated stake,
  • it is possible to restrict an entrypoint to users owning at least X tez by asserting that the received AMOUNT is at least X tez and paying back the amount to the sender.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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