Equivalent of Struct from Solidity in Sohpia available?

Hello All,
I am new to Sophia language and have been exploring the environment for sometime now.

I am implementing a Hashed TimeLock Contract in Sophia for which I am facing an issue.
To explain a bit more about the functionality which I am looking forward to build is that, I need to create a structure datatype which I should be able to instantiate with different values and use as required as we do in solidity.
// =========
// Here is my struct from solidity SC implementation
struct TimeLockContract {
address payable sender;
address payable receiver;
bytes32 preimage;
bytes32 hashlock;
uint amount;
uint timelock;
bool withdrawn;
bool refunded;
// =================
I need to convert this to Sophia compatible version.
I see that there is ‘record’ datatype in solidity, which I believe holds only single values for the key values pairs mentioned.
The functionality which I am looking forward to is, how to I extend the ‘record’ for multiple instantiations.

I am thinking of list of ‘record’ is one way to move(if such a thing is possible in Sophia). but the limit of required number of instantiations would be dynamic. so this approach might no suffice.

Any information/direction in which I should look forward to achieve my functionality is welcomed :slight_smile:


you can use record to create your own data structure with fields of specific types, see Features - æternity Sophia Language

Equivalent should look like this:

record TimeLockContract =
    { sender : address,
      receiver : address,
      preimage : bytes(32),
      hashlock: bytes(32),
      amount: int,
      timelock: int,
      withdrawn: bool,
      refunded: bool }

then you can just use TimeLockContract as any other type within your contract.

also there is an old implementation of JellySwap that used HTLC if you wanna look at this:


Thanks @marco.chain for this answer. Let me go through the link that you have provided.
Will surely get back here. :slight_smile:

also you should check out the latest release of aeproject: