6

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 1

4

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.

5
  • 2
    That’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.
    – lefessan
    Feb 14, 2019 at 8:47
  • Yeah, we're developing a framework to help with this. Feb 14, 2019 at 9:03
  • At some point, Liquidity will have native support for that too.
    – lefessan
    Feb 14, 2019 at 9:21
  • @FLFOCP perhaps write this as a separate answer ?
    – Ezy
    Feb 14, 2019 at 10: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/…
    – arvidj
    Dec 3, 2019 at 13:53

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.