The Future of Decentralized Escrow: Smart Payments
Blockchain Development
A Smart payment, which occurs via a Hashed-Timelock Contract (HTLC), is a transfer of Tokens where the payment condition is enforced by the Blockchain. It is a concept originated within the Bitcoin community that is applied on Lightning Network and can be used on Ethereum, and in Cosmos chains
Condition is a Hashlock.
A Hashlock or the digest of a cryptographic hash function, such as SHA-256, is a type of impediment that restricts the expenditure of an output until a specific piece of data is
publicly disclosed. Hashlocks have the useful property that once a Hashlock is made public, any other Hashlock protected by the same key can also be opened. This allows for the creation of multiple outputs that are all encumbered by the same Hashlock and that all become executable at the same time.
The timelock is a time impediment, like a time safe, where the Smart Contract states that the recipient can claim the funds by presenting
a valid pre-image of the hash digest before a specified deadline (timeout). After the timeout, the funds are automatically returned to the sender.
HTLCs are enforced by the Blockchain, so the transacting parties only need to trust that the Blockchain is executing the contract correctly, (not the counterparty.) It can also be expected that HTLCs can be executed on different Blockchains and even without the presence of a Blockchain, with Agreements (HTLAs).
Conditional Payments
Two parties using an HTLA on a Blockchain that does not support Hashlock and Timeout could proceed as follows: the sender sends a message to the recipient telling it that it wants to “prepare” a transfer with a specified Hashlock and Timeout. The parties agree that if the recipient submits the pre-image hash before the
Timeout, the transfer is executed and the sender owes the money to the recipient. Debts are settled through simple transfers on the Blockchain.
In the case of a post-funding agreement, the sender can settle its debt with the recipient for every payment if its Blockchain is fast and has low fees, or once the total amount owed reaches the parties’ credit limit. In this case, the recipient must rely on the sender to pay what they owe. The risk can be reduced by limiting the amount of money the sender can send before payment.
For pre-funded agreements, the sender transfers the amount of a single payment or a large amount to the recipient and benefits from the equivalent of a line of credit.
The recipient then deducts the amount of any “conditional transfer” executed from the pre-funded amount. In this case, the sender must trust that the recipient will not steal the pre-funded amount, but this risk can obviously be reduced by limiting the pre-funded amount.
HTLAs thus work with Blockchains that support Hashlock and timelock (such as HTLC) and with Blockchains that do not support them.
In the future, this methodology could be used in the CommercioPay module in the Commercio.network Blockchain.