Cross-Chain Swaps

A cross-chain swap enables trading tokens across different blockchains, without using an intermediary party (eg. an exchange service) in the process.


Atomic cross-chain swap between public and private network

In order to create a trustless environment for an exchange, a specific transaction type is required that is commonly referred to as Hashed TimeLock Contract (HTLC). Two additional components characterize this transaction type: hashlocks and timelocks. A thorough explanation can be found on the Bitcoin Wiki.

In other words, to reduce counterparty risk, the receiver of a payment needs to present a proof for the transaction to execute. Failing to do so, the locked funds are released after the deadline is reached, even if just one actor does not agree. The figure below illustrates the cross-chain swap protocol.


Atomic cross-chain swap sequence diagram

When talking about tokens in NEM, we are actually referring to mosaics. Catapult enables atomic swaps through secret lock / secret proof transaction mechanism.

Secret lock transaction

Use a secret lock transaction to start the cross-chain swap.

  1. Define the mosaic units you want to transfer to a determined account.
  2. Generate a random set of bytes called proof.
  3. Hash the obtained proof with one of the available algorithms to generate the secret.
  4. Select during how much time the mosaics will be locked and announce the transaction.

The specified mosaics remain locked until a valid Secret Proof Transaction unlocks them.

If the transaction duration is reached without being proved, the locked amount goes back to the initiator of the secret lock transaction.



Locked mosaic.


If reached, the mosaics will be returned to the initiator.

Hash Type

The algorithm used to hash the proof.

Hash Type ID
SHA_512 0


The proof hashed.


The address who will receive the funds once unlocked.

Secret proof transaction

Use a secret proof transaction to unlock secret lock transactions.

The transaction must prove that knows the proof that unlocks the mosaics.


Hash Type

The algorithm used to hash the proof.


The proof hashed.


The original proof.