Locking in digital dealing with LexLocker

Ross Campbell
LexDAOism
Published in
8 min readJul 19, 2020

LexDAO introduces full-service smart contracting for deals built with Aragon and Legal Engineering

Photo by Charles Deluvio on Unsplash

Intro: The State of Digital Dealing

Imagine you want to hire someone to do something right now on the internet.

Let’s say … Bob wants Alice to code a simple dApp for his super awesome crowdfund smart contract.

Usually, after this request is hashed out on a private messenger, go-to-deal-flow is like so: 🌊

B: Hey, how does 500 bucks sounds?

A: Cool. That works. Here is my venmo, and if you have dai, my 0x address.

BUT, we can’t all be friends like Bob and Alice and trust promised work and money will move together, can we? 🤷

Most work-for-hire and delivery-of-goods deals are between total strangers. . . who have no reason to trust each other when they make promises. Also, obviously, strangers don’t have the same social enforcement tools, like “shame on you Bob, wait until your mother hears about this!”

tribal deal security simplified. source

But we need to get things done and be able to plan around commitments. Otherwise, good luck building an economy ~~~~

So, we lean on the august laurels of The LAW and include ‘trust experts’ to help eliminate the Stranger Danger of doing deals and engaging in commerce … like Lawyers and Bankers to draft and enforce promises with a degree of certainty that approaches tribal social enforcement (Package arrived! Code completed! Research drafted! If matching legal terms ~💸💸💸).

At LexDAO, the flagship legal engineering guild, we have long realized code can arrange this CORE DEAL PATTERN way better via Ethereum smart contracts that escrow value, update, and financially sync to signatures by parties 🤖.

SO, logically, in addition to building on our core offering and reputation of “Throwing Legal System in Code” by vetting and placing arbitrators into DAOs and shilling ‘governance as a service’, we have built a series of products, starting with LexLocker, that integrate directly into LexDAO digital arbitration and are designed to optimize deal flows for our own clients.

No lawyers. No banks. Less problems getting what you paid for. Sound good?

Introducing LexLocker

Let’s get through the basics:

LexLocker is a highly-legible, and, *mercifully for security auditors, brief, smart contract in ~300 lines that (i) escrows Ether and any ERC-20 token for timed lump sum or milestone payments 🔐, (ii) hard records offers by potential CLIENTS for PROVIDERS to do stuff for digital money 📜, and (iii) includes a swift and predictable dispute resolution mechanism, ENTIRELY ONLINE / ONCHAIN ⚖️.

let’s get digital. source

What does this even mean?

Bob can lock 500 dai into LexLocker with his request for coding a dApp, and after Carol (our stranger …) performs, he can release it right away and everyone’s happy 🌈. No fuss, no frills, no middlemen, only dealing.

Evidence of this completed digital deal is plain as day and hard to dispute. If the deal timer runs out (“Can you do this before next Friday?”), Bob can retrieve his escrowed funds, no questions asked. IF there is a dispute before the timer by Bob or Carol, they can receive arbitration in minutes from LexDAO. That’s it!

IN FULLER TURN:

With escrow and programmatic payment release, we have knocked out banks and escrow agents as choke-point for payment performance. Carol can see Bob is good for the money (i.e., not just sitting in his spendable MetaMask wallet …). Carol can also read the code and audit that Bob’s money will move forward predictably after she holds up her end of the bargain.

With hard records on the Ethereum blockchain and LexDAO templates under-girding deals (more on that in another post ;9), we have drastically reduced the need to talk to lawyers to set market terms in writing for judges to interpret if things goes south, as well as eliminated constant deal maintenance overhead, such as safekeeping signed legal docs / managing related data security so hackers don’t forge new terms.

Finally, with LexDAO digital arbitration ready the moment a LexLocker party signs to lock their deal and get their case heard, we have accelerated the timeline to finality. In LexLocker, funds are already deposited and under LexDAO governance by default; therefore, the moment one of our judges reaches a decision, reading straight from the LexLocker deal records and signing resolve, parties get their judgment awards. If this award is attacked in a court, the parties can refer to the LexLocker contract that clearly defines private resolution on agreed terms.

simplicity in solidity for security. source

How Deal Deposits Work

Starting a LexLocker deal simply involves a client paying a deposit into the smart contract and recording their offer details for a provider to potentially satisfy. NO fee is paid to LexDAO related to a LexLocker deal unless a dispute is created and successfully resolved.

The actual deposit and escrow of funds into LexLocker uses the familiar transferFrom function of ERC-20 tokens to automatically escrow a paymentcap (total sum offered to pay for work) that can be further divvied up into milestone amounts .

Milestone amounts are enforced by a single require statement:

require(amount.mul(milestones) == cap, "deposit milestones mismatch");

To illustrate some uses:

In the case of Bob paying Carol 500 dai for some coding work, he would deposit a 500 dai cap with matching base amount if milestones weren’t useful. Just as easily, Bob could write an offer into LexLocker for 5 milestones of 100 dai amount with 500 cap and have these terms enforced and paid out precisely as work progresses.

In order to accommodate the use of raw Ether in LexLocker, as well as remove the pain-point of ‘wrapping’ to tokenize this native Ethereum asset, LexLocker automatically converts Ether into wETH, using a custom enhancement our legal engineers are stoked to share:

if (token == wETH && msg.value > 0) {            
require(msg.value == cap, "insufficient ETH"); IWETH(wETH).deposit();
(bool success, ) = wETH.call.value(msg.value)(""); require(success, "transfer failed"); IWETH(wETH).transfer(locker, msg.value);
} else {
IERC20(token).safeTransferFrom(msg.sender, locker, cap);
}

We further make use of ConsenSys Diligence’s recommended sendValue pattern to transfer raw Ether and maintain code security against protocol upgrades that seem to be deprecating older Solidity patterns, like call.value and transfer.

Never wrap your ETH again to do smart contract stuff!

How Deal Records Work

LexLocker is essentially an index of deals stored as structs in Solidity by a paying client for their chosen provider:

struct Deposit {          
address client;
address provider;
address token;
uint8 locked;
uint256 amount;
uint256 cap;
uint256 judgmentRate;
uint256 released;
uint256 termination;
bytes32 details;
}

In this manner, each deposit is reflected by hardcoded terms arranged in an permission-ed ‘object,’ where only deal parties, and upon dispute, LexDAO can interact. A living onchain legal contract.

Everything happens in one locker, deployed here on Ethereum mainnet: 0x6d2A62442dAf0448561d130b40BaC6159264b1c0

As can be seen from the variables of each LexLockerDeposit, the parties themselves or a reviewing judge/arbiter can easily track the progress of an active LexLocker deal, such as the type of ERC-20 token, the use of milestones to schedule payments, and how much has actually been released from the total cap of the escrowed funds.

How LexDAO Arbitration Works

As noted, each party to a LexLocker can call the lock function on their deal and freeze the release or withdrawal of remaining payment tokens left in Deposit. IN most cases, this will be upon dispute, but might also be used for ‘efficient breach’ or security/fund recovery purposes (e.g., if counterparty account is compromised)

To hash out a dispute: Bob might have paid 3 milestones under his 500 dai deal locker for coding work, 300 dai, and then said “Hey, Carol, I actually think I’m good with what you’ve sent so far! When timer concludes, I will withdraw the remainder. Thanks again :~0!” If this wasn’t part of their deal terms (details), Carol might respond, “Sorry Bob, but we agreed that this job was worth 500 dai, and milestones were arranged for convenience. I want to see this out. But to help us resolve and finish this up quickly (boo distractions), I have called to lock our deal for LexDAO resolution. ;~0”

After LexLocker ADR is initiated, Bob and Carol can keep calling the lock function to simulate complaint/response motion practice and provide evidence onChain (providing updated details). They can also submit evidence privately to LexDAO arbitration through our channels provided on lexdao.org.

LexDAO, the Who, the What???

Legal Engineering for Hire

LexDAO first and foremost is a guild of legal engineers drawing on progressive legal and coding disciplines to make deals way more awesome. We have been organically training and certifying lawyers for digital arbitration and other rarefied skills for the past year, and now, have a critical mass of 9 Legal Engineers and 2 Apprentices that can weigh evidence and swiftly resolve disputes as a professionalized and legally-insightful alternative to Kleros and Aragon Court.

Using an Aragon DAO under the umbrella of LexDAO Cooperative (LexDAO LLC), we have collected our Legal Engineer accounts as an 11 member DAO, and programmed LexLocker to only permit these LexDAO Judges, holding a balance of at least 1000 DAO tokens, to resolve disputes. This DAO further acts to upgrade the required judge tokens, fees, and other balances required to operate LexLocker using an Aragon agent smart contract that only executes after member votes fully pass.

To incentive our individual arbiters to quickly unlock deals that are in dispute or other insecurity, each resolving LexDAO Judge receives a tokenJudgmentReward directly from LexLocker that pays out against the current 5% resolution fee paid to the DAO treasury.

Wrapping it Up

The LexLocker smart contract and arbitration system through LexDAO on Aragon are ready for online dealing. Anyone can enter into LexLocker right now on Ethereum and have Legal Engineering assistance to save on money and stress and work through very common deal patterns.

Looking ahead, we will be publishing mock dispute opinions in the coming week to illustrate our approach to resolution and making awards recognizable to courts. Further, we will be pushing out interfaces to make it easier to use the LexLocker smart contract and send dispute details to LexDAO judges with privacy.

Overall, we hope folks, and especially front-end devs, see this an opportunity to also build their own dApps and businesses around LexLocker and LexDAO arbitration, and welcome anyone to elect LexDAO Judges (subDAO) as a resolver for your smart contract disputes (0x06153608b799a3da838bf7c95fe21309d2e33b53) or build directly on top of the LexLocker flow (0x6d2A62442dAf0448561d130b40BaC6159264b1c0).

Questions on how to use or build with LexLocker? Check out our Discord 🎮. Follow us on Twitter 🐦.

Until next time ~ soon! 👋

--

--