Calling other contract functions from within a contract

How do I call another contracts’ function from within one contract?
Do I need to include/import the callee contract that I need to call from within a caller contract? If yes, how?

The following is a sample code:

contract Callee = 
   // has some state
   // has an init function
   
   stateful entrypoint calleeFunction(param1: int, param2: address) =
      require(Call.caller == state.owner, "Only owner")
      internal_function(param1: int, param2: address)

   stateful function internal_function(param1: int, param2: address) =
      // some logic here; state is modified

Without importing the Callee contract, I’m getting this
type_error: Unbound type Callee

// How to import??

contract Caller = 
   // has some state
   // has an init function
   
   stateful entrypoint initiatorFunction(calleeContractAddr: Callee ,param1: int, param2: address) =
      calleeContractAddr.calleeFunction(param1, param2)

Also, the initiatorFunction of the Caller contract will take the address of the Callee contract as the first argument as per the example, right?

@hanssv.chain @philipp.chain can you help?
TIA!

Hey, can you compare with the documentation for calling other contracts? aesophia/sophia.md at lima · aeternity/aesophia · GitHub

Thanks @philipp.chain I did that and my sample code is based on that itself. But it’s not solving my problem. I’m still unable to initialise and call external contracts.
Can you help me figure out what I’m missing?

Where is the contract type? If you replace “How to import??” with that you should be good.

contract Callee =
   entrypoint calleeFunction : (int, address) => _whatever_internal_function_is_returning_
1 Like

That’s exactly what I was missing @hanssv.chain
Thank you so much.
Wondering why that’s not specified in the documentation @philipp.chain posted

It is specified… About two lines above the VoteTwice contract?!

// A contract type
contract VotingType =
  entrypoint vote : string => unit

Thank you. I seem to have missed it somehow!