Rsquad has been involving in the development of Free Ton technology since its start.

Rsquadlab
5 min readApr 5, 2022

In 2020, there was a competition for the implementation of Atomic Swap development, in which Rsquad was competed with other professional teams.

Cryptocurrency’s holders want to work with e-money and exchange it without intermediaries. Stakeholders have matter of trust in a third party and the security of the transaction, while collaborating with custodian exchanges.

Atomic swap — alternative technology of exchanging and your solution for solving above-described issues. Using of Atomic Swap does not depend on TEE (Trusted Execution Environment); however, it is invulnerable to exposure.

For different cryptocurrency idea of atomic swaps works another way. Exchange without intermediaries through unlimited blockchain networks that could implement these technologies, but for a particular network, it is unique.

According to the terms of the Free Ton competition, the exchange must be made for the Free Ton, Ethereum and Bitcoin networks.

How it should work

If you are the initiator of the exchange, fill out the form: how much currency you are ready to give, how much you want to receive, enter the address from which you will come for your money.

Wait for someone to respond to your order, and when you have a partner, tell him the ID.

As soon as they answer it, produce a secret key, it is also a password, enter the timelock — the time allotted for the transaction, and send the transaction.

In the case of Free TON, the transaction is signed and sent directly from the browser. In Ethereum, MetaMask will do everything for you. In the case of Bitcoin, you will see a transaction that you need to send yourself using a convenient wallet.

Wait for your partner to respond to the order, respond and send their transaction with your details.

Withdraw funds from your partner’s box, specifying the correct secret.

Once you have withdrawn the funds, the other party to the transaction will see this and, using your secret key, will receive the money you sent.

You will receive funds without third parties. Minimal movement — maximum benefit!

What does the tender decision consist of?

In general terms: the initiating user expands the box to which he sends:

tokens;

address of the recipient;

hash of the private key;

sets a timer;

passes the address to the receiving user.

Boxing transfers funds either to the specified recipient if he transfers the secret key, or to the user who created it, but only after the blocking time has expired.

The receiving user creates his box on another network with a similar data set. The recipient specifies the initiating user and, necessarily, a much shorter time interval.

It is important that the initiating user does not take funds from someone else’s box and tokens from his own, thereby deceiving the second party to the transaction.

It sets the required number of tokens and expands the box with the same hash of the secret key. Then the receiving party transmits the address of its box to the initiating party.

The initiator takes tokens from the recipient’s mailbox and writes down the secret key. It is important that the contracts of both networks can correctly figure out whether the secret key is correct or not.

The receiving party sees the secret key in his mailbox, transfers it to the initiating user, and receives tokens.

If one of the parties did not unfold its box, did not write down the secret key, did not come to pick up the funds, then after the blocking time expires, the creator of the box will return his money.

More about implementation

In the center of the system there is a register holding information about offers for exchange (boxes). The registry registers only those offers that are created through the system, thereby ensuring that the box code is correct, and it is not tampered with.

In addition, the register has other functions to ensure the system and check the correctness of transactions.

The box holds swap data (e. g. recipient, timelock, and so on), stores tokens and a secret after it is revealed.

Complete is a method that transfers funds to the recipient after specifying the correct secret.

Reclaim is a method that returns money to the creator if the deal fails and the timelock has expired.

About software

Programming languages — Javascript/ionicJS;

Development of smart contracts — Bitcoin, Ethereum, Free ton, Solidity.

This set of tools allows you to efficiently, inexpensively and most importantly — safely carry out the necessary exchanges in any volume.

As a shell for operations, a server part was created, the purpose of which is to track the status of the transaction and help users find partners. All she stores are orders and box address so that both parties can conveniently receive the information they need from each other.

Front-end solution is implemented to prove functionality and use ton-client-js and Metamask for sending transactions. For Bitcoin, transactions will be generated in the browser, but they will have to be sent from a tool that is convenient for you.

The interface part is based on ionic, therefore it is convenient for fast cross-platform functionality, so the delivery of mobile and desktop applications for popular platforms will not keep you waiting long.

The smart contracts code is posted in the open RSquad code repository and is available here

All in all

Tender format gave us an added incentive and a powerful impetus in professional and research activities. Considerable work has been done because of which we became prize winners of the competition.

Rsquad company has showed competence in the FreeTON project, confirmed its position of strong developers in the community.

In addition to the system of secure atomic exchange, Rsquad has developed a software solution interface that is clear and intuitive for the user, it has a design, layouts, and identity.

The result is not just a bare technology, but a useful product that can be changed, assessed, and put into commercial operation, using not so much effort and time.

--

--

Rsquadlab

RSquad is a international team of experts specialized in the development of decentralized information systems based on blockchain technology.