Atomic Wallet swaps, or atomic cross-chain trading, is the exchange of one cryptocurrency to another cryptocurrency, without a third-party risks:
The first party (called the initiator) wishes to trade Coin B for Coin A with the other party (called the participant).
The initiator allocates the intended amount of Coin B to a contract and generates a “secret”. The secret will later allow the participant to collect the contract output. Until he/she learns the secret, the participant is unable to spend from the initiator's Coin B contract.
The participant creates a contract on the Coin A blockchain in a similar to the initiator fashion. To create the contract, the participant requires a cryptographic hash of the initiator’s secret. The initiator could not access this contract without revealing the secret to the participant.
After both parties created their contract, neither of them can collect their coins back until the alloted time expires. The initiator redeems the participant’s contract, thereby revealing the secret to the participant. The latter redeems the former’s contract using the secret extracted from him/her.
When a certain period of time (typically 1 hour) expires and the participant did not redeem the contract output, it is refunded back to the initiator's wallet. The participant's contract can also be refunded back to the participant, but only after half the period of time that the initiator is required to wait before their contract can be refunded (typically 2 hours).
The initiator can also trade Coin A for Coin B and the procedure will be the same, but with each step performed in the opposite direction on another blockchain.
This procedure is considered atomic (i.e. with a timeout) since it gives each party at least 24 hours to redeem the coins from the opposite blockchain before a refund can be performed.
How it looks in the Atomic Wallet:
In the meantime, check out our Cardano Wallet.