How to write interfaces in Sophia

Greetings Everyone,

Can someone please point me or tell me how to write interfaces for contracts to standardize operations. For e.g a fungible token (I am aware of AEX9) but the implementations can be compromised.

I saw this in docs inside this title https://aeternity-sophia.readthedocs.io/en/latest/contracts/#splitting-code-over-multiple-files

Please let me know any solution to including interfaces in Contracts in such a way that all methods should be required to be defined in the child contract.

This is a nice resource and looks very close to what I want to do but don’t know exactly how to add those interfaces in that way (described above) https://github.com/mradkov/aeternity-fungible-token/tree/master/contracts

3 Likes

Currently there is NO support in the sophia compiler for contract interfaces, contract polymorphism or parametrized contracts. Perhaps in the near future we might address this issue CC: @radrow

6 Likes

Ok, thank you.

1 Like

Currently contract interfaces are useful only to define contract types for remote calls (so you know the types of entrypoints). There are plans for contract inheritance, but it is not prioritized.

1 Like

got it, thanks

1 Like

I just asked this in the Telegram channel. I think it would be an useful feature to have some sort of enforced entrypoints defined by an interface or behaviour. For my particular use case I was looking for a way for the Sophia compiler to error on missing entrypoints that I forgot to implement based on a “behaviour contract” callbacks. Hope it makes sense.

2 Likes

Hi,
This question was actually asked for the same purpose. But as the contributors above said, There are plans but not prioritized.

3 Likes

Could you make an issue on github for this? This feature would be feasible to implement after we get done with some more prioritized stuff.

3 Likes

Sure, Please let me know if I should add anything here https://github.com/aeternity/aesophia/issues/307

2 Likes