This DeFi smart contract from Intercoin might make crypto 10x more mainstream and useful for everyday transactions. It works to align everyone’s incentives with win-win outcomes in off-chain transactions. It can do this even for parties who don’t know each other, massively reducing the need for external judges or community reputation systems (though those can sometimes help). Read below to see what problems it solves, and further down learn about how it works.
Limitations of Bitcoin and Ethereum
As you already know from reading Intercoin’s articles for any length of time, global blockchains are slow. Global consensus is very expensive and doesn’t scale, as their own main developers acknowledge. Having to store all of it and expend massive amounts of electricity the full infrastructure can now only be run by powerful elites, to power a precious 20 transactions per second.
And yet these platforms are immensely popular, and a lot of value has been invested in these ecosystems, represented by digital coins and balances. Why? A lot of it has to do with a new way to enforce transactions: code that you can rely on to do what it says. But, such code does not, by itself, represent a full solution to resolving disputes and creating a cost-effective environment for successful transactions.
There are many reasons to do transactions off-chain. There are no bottlenecks, and things can be done very quickly and privately. People can engage in complex transactions without running code on a “world computer”. And finally, not everything in the real world can be represented or litigated so easily on a blockchain:
Guilt and Enforcement
The oracle problem is that the data fed into the blockchain could be wrong (e.g. a painting could be stolen), but the immutable blockchain puts total responsibility on the buyer to know everything before the transaction is concluded (“buyer beware”). It is not always clear who is at fault for breaking a contract, and for how much. What if someone sold defective goods on eBay, or sold a gift card but then used it? What if the recipient is the one lying, instead?
This also presents a large mismatch between the crypto economy, and the traditional banking economy with credit cards and chargebacks (“seller beware”). Today, we have various systems of arbitration and reputation that can allow for non-violent conflict resolution, e.g. by clawing back the money custodied by a third party bank.
Sometimes, these systems consolidate and become quite large and powerful. The payment processor duopoly holds a lot of power in the USA, and can be used to merchants. China has gone even further, creating a controversial credit rating system to police regular people by making them lose money or privileges for doing “undesirable” things.
Background to the Idea
The idea was originally inspired by twitter wars of Bitcoin developers criticizing Ethereum developers for their “smart contracts”. You see, Bitcoin has a programming language, but by design, it’s very simple (it doesn’t have support for loops, etc. so it’s not Turing-complete.) The Bitcoin guys said that Bitcoin does have support for making people cooperate, like in a smart contract: both parties simply lock up some amount of Bitcoin in an address, and it takes a both parties to create a multisignature to release them back. It’s MAD escrow (which stands for “Mutually Assured Destruction”).
If the transaction doesn’t go well, then one or both parties won’t be willing to release the money. If both parties get some money locked up, it creates an incentive on both sides to have a successful transaction. In fact, if the amount locked up is 100% or more of the total value of the transaction to each of the parties, there is a strong incentive to work things out.
Ethereum transactions can only have one signature, but the data in the transactions can include signatures from multiple parties. This enables us to build a complete solution, of which one part (written in Solidity) takes place on the Ethereum blockchain, and other parts are written in Web technologies and programming languages we are familiar with for years. Once deployed, people would be able to use the Intercoin website or app to facilitate successful transactions with people they have never met, often without the need for outside communities, reputations, or third party custody or adjudication.
When you are engaging in large transactions with people you don’t trust, you can mitigate any loss by sending small packets of money. This is the idea behind Interledger Protocol and Coil a company started by Stefan Thomas, former CTO of Ripple. Coil has recently helped pass the Web Monetization standard, and together with Mozilla they have raised a $100M fund to help monetize content and services on the Web. (Incidentally, Qbix has pioneered a different approach to the same issue, which can work hand in hand with this
EscrowContract by Intercoin).
How It Works
EscrowContract generalizes all the above considerations into a general-purpose framework. Like all DeFi smart contracts from Intercoin, everything that should be customized, can be customized. Our interface will allow customizing and deploying contracts using your own web3-enabled Ethereum wallet, such as MetaMask or Trust Wallet.
- The contract allows anyone to
create()a new escrow, and returns a unique
idfor it. Optionally, a
whitelistcan be passed, so only certain addresses can join this escrow. Here we can also specify the type of external token (ETH, USDT, utility tokens, etc.) that can be locked up in the escrow.
- Then, participants can
deposit(escrowId, amount, untilBlock)to send a certain amount of tokens to the contract, and create a deposit to be locked. The function returns the
indexof the deposit under the
- Each of the participants in an escrow can then call
lock(escrowId), and when the last participant does so, the contract will lock all the deposits at once, until their respective blocks, or indefinitely, depending on what the parties have agreed to do off-chain.
- The participants then send receipts off-chain to each other, which contain signed data which can be posted to the blockchain. Each receipt must be signed by M of N participants, and can be used to unlock a given amount of previously deposited tokens.
- As the transaction progresses (some real-life projects take months or years), each participant can accumulate receipts with greater and greater amounts to unlock. The amounts aren’t added together. Rather, each receipt simply contains the maximum amount that can be unlocked, and the amount in subsequent receipts can increase monotonically.
- At any time, a participant can post a transaction with the data from the receipt, signed by M of N other participants, to
redeem(amount)and get it back into their account. As explained above, this operation is idempotent.
- There can be an alternative mechanism, whereby both participants can call
swapAndUnlock(depositIndexes)and when it has been called by all depositors of
depositIndexesarray, the swap takes place (shifting the array by 1) and the deposits are unlocked for each new owner to withdraw it. This is to effect simple swaps of 2 or more locked-up deposits.
- In the end, a successful escrow would leave no amounts still locked inside it. A negative reputation could arise from an address having too many escrows where others don’t want to unlock the rest (thus harming themselves, as well).
This mechanism could be used in many different ways:
Exchanging large amounts of value on-chain. Two mutually distrusting parties could quickly send each other $1,000,000 with no intermediaries and minimal on-chain fees. They could create two escrows in our
EscrowContract. One would lock up $1,000,000 worth of
USDT, the other $1,000,000 worth of some other ERC20 token, such as
FIL. Then both would call
lock() followed by
Exchanging large amounts of value off-chain. Two mutually distrusting parties could send each other $1,000,000
They would then proceed to take turns sending each other pre-signed receipts of their respective tokens, starting with $100 and increasing by $100 until they reach $10,000. At any moment, these receipts can be deposited, with
B withdrawing the
A stops at $300 and refuses to send more
B, both parties would be stuck with their respective money locked in the smart contract. It would be in their interest to work out whatever problem they have, because they stand to lose more if they don’t.
As both parties come close to $10,000, they increase their respective deposits to $20,000 or perhaps more, to get the transaction done. Here, mutual trust is built not through reputations or third parties, but the amount each participant has locked up.
Buying goods online Often, people on online marketplaces like eBay or Amazon, rely on ratings and reviews to infer a seller’s or buyer’s reputation. The product itself may still need ratings and reviews, but now, we can largely replace the need for reputation system with escrow. This can also be used for domain names, and ownership of other digital content.
Both parties can deposit USDT exceeding the value of their transactions. Both the buyer and seller would lock up $50 for a $90 product, until the transaction is complete. At any given time, a seller could keep $10,000 deposit with the public Ethereum blockchain, rather than Amazon or an escrow account, and do $10,000 worth of “secure” transactions at at time. As their volume grows, so is the amount they would deposit (perhaps borrowing it from an on-chain lender).
As the various steps in the transactions are completed and verified by third parties to the satisfaction of the participants, they send each other receipts, and finally, when the item has been received in good condition, the buyer sends money to the seller. In turn, both of them send receipts to release the escrow. Otherwise, they’re both motivated to make things work, or lose $50.
Paying for Services When someone does a job over a period of time, the job can be split into milestones and deliverables. As each milestone is completed successfully, the client can send the vendor the money, and each of them would exchange receipts to release each other from their escrow. Service providers could have $10,000 locked up as they work with dozens of clients, and similarly, clients could have $10,000 locked up as they work with dozens of service providers. Alternatively, for a $80,000 project, both sides could lock up an entire additional $40,000 and release it piecemeal, thus motivating both sides to work out their differences and lower the escrow as the project nears completion. If a vendor can’t complete the project, for example, they may agree to pay the client a $5,000 penalty for both sides to release the rest of the escrow money. All these transactions can happen incrementally off-chain, and only the final results are posted to the chain.
Renting, Leasing, Lending Whenever someone rents anything, the security deposit can be held in this kind of escrow. As time goes on, the security deposit can be reduced, with mutual agreement of the parties.
This is one of a suite of DeFi contracts Intercoin is working on. People should soon be able to use the Intercoin website or app to facilitate successful transactions with people they have never met, often without the need for outside communities, reputations, or third party custody or adjudication.