Contract Address as parameter

Hello All,

I want to pass a contract address as parameter to a function in sophia.
but address only access account address and not contract addresses.

Somewhere in the community I read we can use the keyword contract literal inplace of address. But, it’s not working for me. I am getting an exception, Unexpected token 'contract'.

NOTE: I am testing the contracts on my local(macos) with aeternity javascript sdk version - 4.0.0.


I can see that the official documentation of aeternity sophia lang confirms that to pass contract address as a parameter to a function, we should use the literal contract.

But this simply doesn’t work.

1 Like

Hi @Jkrish1011

What you see at is the type contract literals which Sophia knows to handle, not the keyword contract.

From what I understand what you want to know is how de specify to some arbitrary contract to accept parameters of some other contracts.

For example, If you have a contract named MyContract and you have another contract that has an entrypoint expecting as parameter a MyContract address, you simply have to set the type of the parameter as MyContract.
Let’s say you have:
entrypoint my_function(the_contract_address: MyContract) = ....

Do not forget to have MyContract definition included in the contract file that needs it
include './MyContract.aes'

in the javascript side, you just have to call the function with the contract address



do you mean @aeternity/aeproject? @aeternity/[email protected] is too old, the last one is 12

1 Like

HI @davidyuk , thanks for notifying.
my @aeternity/aeproject is version 4.

1 Like