1

Is it possible for contract X to read the storage of contract Y without making a transaction?

I think I understand how I can make X call a function on Y using a callback pattern. But since I only want to read the storage of Y - and they are on the same ledger - the data should be readily available to X without making any transactions?

2 Answers 2

1

For an updated answer, views have been added when the Hangzhou protocol was activated.

They are known as "On-chain views" and their usage with the various high level contract languages can be found searching this term.

2

It is not possible for a contract X to access the storage of contract Y against Y's will. The main reason to forbid this is to prevent ticket steal. For contract Y, allowing contract X to read some part of the storage is typically done using the view pattern of TZIP 4 but in the future first-class views might be added to Michelson.

1
  • It could be done through an explicit unpair which would protect against stealing tickets.
    – FFF
    Mar 24, 2021 at 0:07

Your Answer

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

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