Can view methods be used for cross contract calls? (Getting error HostError(ProhibitedInView { method_name: "promise_batch_create"})

Solution 1:

This article explains the issue https://docs.near.org/docs/develop/contracts/as/intro#view-and-change-functions

view calls do not provide the same context as a change call

the reason is because view calls are unsigned. no sender has signed a transaction to make the call. this is useful, not requiring a signature, because some use cases are intended for casual browsing or frequent reading of data like browsing an NFT collection or rendering a dashboard

change calls require a signed transaction so they include context like sender and other details

cross-contract calls require gas and this gas should be charged to some account. without a signed transaction (in a view call) then there is no one to charge for this gas

this might make you wonder: "but don't view calls cost gas too?" ... yes, they do, and today the RPC node providers are subsidizing these calls but that may change in the future