Atomic swap on Pascal blockchain: How to perform secure ‘time-bound’ swaps.

Pascal Blockchain
5 min readFeb 15, 2021

Atomic swap is a smart-contract technology that enable secure and time-bound asset exchange without using intermediaries, such as 3rd party exchanges. Atomic swap transactions are smart-contract events within the respective blockchains involving only the exchanging parties in a cryptographically secure manner. With the atomic swap technology, assets are exchanged with blockchain-level security.

To facilitate secure, time-bound and automated asset swap on the Pascal blockchain, we have developed the Atomic Swap feature, creating opportunities for very exciting use cases.

How the Atomic swap works…

Atomic swap protocol works using the Hash-locked-time-contract smart contract. With the Time contract protocol already implemented on the Pascal blockchain in form of ‘in-protocol PASA exchange’, introducing the hash locked account feature completes the atomic swap smart contract. This feature uses a time lock differential to ensure secure exchange of tokens on the Pascal blockchain and also cross-chain cryptocurrency exchange.

From the client-side; the atomic swap work flow is simply thus: for an exchange of specified tokens, the seller locks a certain amount of tokens in his/her wallet using a random secret number. This number must be revealed to the second party for this swap to occur. To reveal this number to the second party, the second party must satisfy their part of the agreement. This could be a contract agreement, asset exchange… The time lock is set to a specified time after which the transaction is invalid.

For instance, if Tom wishes to purchase a special PASA from Harry for 50PASC:

Tom stakes 50PASC to Harry’s wallet and sets a secret code which must be supplied by Harry before the 50PASC in staked to His wallet will be accessible. He also sets a time frame after which the deal becomes invalid if Harry fails to satisfy his part of the deal, (Tom might set a 5days time frame)

• To redeem the staked 50PASC, Harry must have a knowledge of the set secret key.
At this point, Harry can take Tom’s 50PASC for free only if he could supply the secret number set by Tom.
• Where integrity is in doubt, both parties can set up a trusted third party to oversee the transaction. Tom hands over the secret key of the third party.
• To validate this agreement, Harry sets up another atomic swap transaction to transfer the PASA in bargain to Tom’s public key. Harry sets a time frame for this transaction after which it becomes invalid if Tom fails to publish the secret code.
If Tom sets 5days for his transaction, Harry may pick a 1–4 days’ time frame for Tom to supply the secret number, this is known as Time lock differential, this serves a very important security purpose

The Time lock differential gives Harry enough time to cancel transaction if he notices an abnormality on Tom’s side, probably if Tom fails to reveal his secret. Harry also supplies his secret number to the trustee.
• Tom detects the transaction set up by Harry on Pascal blockchain, he then reveals his secret number to take charge of Harry’s special PASA.

• Harry detects Tom’s transaction on Pascal blockchain and extracts secret number from Tom executes a transaction to Tom’s account using the secret code as a payload. This validates the claim and completes the swap.

Step-wise guide on how to perform an Atomic swap transaction on your Pascal wallet

To set-up an Atomic swap transaction:

  1. Select ‘list account’ from the options below your account details

Two atomic swap options are available. ‘List for Atomic account swap’ allows set up an account exchange operation using the atomic swap protocol. ‘List for Atomic coin swap’ allows you set up a coin exchange operation using atomic swap protocol. Both processes are similar.

  1. Select ‘list for Atomic coin swap’ and enter the required details.

The ‘Time-lock’ allows you set a time interval for which this swap operation is valid. The swap expires if not redeemed within this time interval. A ‘help text’ pops up with details which explains the Time-lock set-up process.

  1. Using the block information provided by help text, set up the Time-lock
  2. Set-up the Hash-lock using a random secret code (determined by you).

In the image above, a random date (09–02–2021) was used (without the separators)

  1. Click ‘set Hash-lock’ to validate the Hash-lock and generate a hash code which carries details of the swap.
  1. Complete other auxiliary details as desired.
  2. Click ‘Execute’ to complete the set-up process.

You can send the Hash code generated in the fifth step to the second party to view the details of the operation. The hash code doesn’t contain the secret code.

You can choose to release the secret code (before or) after the other party satisfies their part of the agreement before the Time-hash.

Any recipient of the secret code can complete the swap by executing a transaction to the swap initiator using the secret code as a payload.

The Atomic swap protocol presents numerous use cases. This service can be utilized in institutionalized contract agreements, automated on-chain and cross-chain escrow operations and numerous payment settlement agreements.

An autonomous betting service currently leverages this feature to validate sports prediction agreement. Click here for further information.

Disclaimer: The Pascal community only recognizes this project as a utility for its blockchain’s features. There are no official affiliations.

--

--