Search code examples
nearprotocol

How to read state of a different contract?


How to read state of a different contract? Like let us say I am in Contract A, how to fetch a state of contract B? I need it to read balances from an NEP-141 contract.


Solution

  • you can't directly read the state of a different contract from within your contract.

    the best you can do is make a cross contract call to the other contract by calling one of its methods

    read more about cross-contract calls here https://github.com/near-examples/cross-contract-calls