I want to have two different contracts that have functions that should interact with each other. Is there a way to pass/return values through function call between contracts?
1 Answer
Contracts don't currently return any data. You should use callbacks for on-chain data transmission, or use an off-chain oracle.
On chain, you use the TRANSFER_TOKENS; instruction to send from contract a to contract b. Contract b would then send data back via another TRANSFER_TOKEN; call. You should update the storage of contract a to acknowledge that a call back is imminent.
-
2That’s the theory. In practice, it’s almost impossible to write it, because of the type system. B has to know the type of A, so either you have to deploy both contracts, or you have to originate an intermediary contract C that knows A and has a type compatible with B. We will post a blog post on that soon.– lefessanFeb 14, 2019 at 8:47
-
-
-
-
The answer to the problems mentioned above are entrypoints, which are described in more detail in this blog post: blog.nomadic-labs.com/category/…– arvidjDec 3, 2019 at 13:53