Middle man discussion

Seems middle man or escrow system is the basic model of every platform. Let’s assume that:

  • Alice has 100 0x01234::CoinA::CoinA
  • Bob has 100 0x01234::CoinB::CoinB

How to create an escrow modules, i mean where should we store resource at midle step.

3 Likes

This is a great scenario for resource accounts. Take a look at AptosFramework::ResourceAccount. You can create a struct with the module as owner/signer that can hold assets in escrow. Similar to PDAs in Solana.

3 Likes

No need for an additional account. Create an escrow module on Alice where she can offer Bob the token and vice-versa. Specifically:

  • Alice or Bob offers
  • Then the other offers
  • At this point the module detects that both has offered and performs the atomic swap by withdrawing from the respective escrow and depositing into the appropriate account.
2 Likes

I’ve understand this scenario

1 Like