Skip to main content

Trustless Swap

This guide and example demonstrate an atomic swap on Sui, which is similar to an escrow but does not require a trusted third party. Instead, this example uses a shared object to act as the escrow between two Sui users wanting to trade. Shared objects are a unique concept to Sui. Any transaction and any signer can modify it, given the changes meet the requirements set forth by the package that defined the type.

info

See Shared versus Owned Objects for more information on the differences between object types.

The guide is split into three parts:

  1. Backend: The modules that hold the state and perform the swaps.
  2. Indexing and API Service: A service that indexes chain state to discover trades, and an API service to read this data.
  3. Frontend: Enables users to list objects for sale and to accept trades.
info

You can view the complete source code for this app example in the Sui repository.

Prerequisites

Before getting started, make sure you have: