[Solved] How to pass remote contract instance in JavaScript SDK?

I have a contract which takes another contract as a dependency. Similar to this example: https://github.com/aeternity/aeternity/blob/master/test/contracts/environment.aes

How can I initialise such contract in JavaScript SDK? Particularly, what needs to be put at initState as argument?

const depInst = ... ;
const inst = compiledContract.deploy({
      initState: args, // <-- how to encode depInst and put it here?
      options: opts,
      abi: "sophia"

Without having the possibility to validate right now, could you try referencing it by its address?

If I understood your intention correctly, speaking of this example

contract Interface =
  function contract_address : () => address
  function call_origin      : () => address
  function call_caller      : () => address
  function call_value       : () => int

contract Environment =

  record state = {remote : Interface}

  function init(remote) = {remote = remote}

  function set_remote(remote) = put({remote = remote})

remote is an address to another contract with the interface Interface

1 Like

Thanks @nikita-fuchs. I also found this tutorial with the same trick: https://github.com/aeternity/aepp-sophia-examples/tree/master/examples/SmartShop
Basically, I wanted to see how JavaScript side looks likes. It seems it is working for me now.

1 Like