Programming your first binding legal agreement with Lexon

mapachurro
Remix Project
Published in
5 min readOct 27, 2020

Conversations listing fields that will get revolutionized by blockchain technology usually don’t include the legal field. This is a surprising omission, after all, smart contracts are contracts and what is more legalistic than a contract!

There are a few entities out there working on deploying law to the blockchain, and it’s a relationship that makes sense. After all, if you’re dealing with a technology that is, at its core, transactional between parties and that wants to overhaul our banking and payments system from the ground up, you’re already dealing with the law whether you recognize it or not. Including a legitimate legal layer to those transactional relationships is an incredible value-added (or often, value saved!) proposition.

What I’m talking about here, to borrow some terminology from Lexon documentation, is the ability to write a legally enforceable contract that is, at the same time, a smart contract. What Lexon is working on is the ability to write a digital expression of a legally enforceable contract, with programmatic capabilities.

Lexon is a jaw dropping a technology that is a melding of linguistics, law, and code on a level that, if not entirely unprecedented, is an achievement in its own right.

Lexon is a coding language that compiles to Solidity (or Sophia, for those playing along on the Aeternity blockchain), consisting of a limited vocabulary of English, designed to come damn close to a holy grail of code: the ability to write grammatical English that, simultaneously, performs computing functions that correspond to what is expressed in the English.

Remix now has a Lexon plugin

I wanted to try out Lexon not with one of the many examples on their website but with a contract I know from experience with the legal profession (not as lawyer, though I do work hand-in hand with them every day). My goal was to see if Lexon would be flexible enough to build something an attorney might actually use. So I grabbed a boilerplate retainer agreement, and sat down to see if I could express it in Lexon. Take a look at what I worked out:

LEX Retainer Agreement.
LEXON: 0.2.12
COMMENT: A boilerplate retainer agreement for legal representation.
“Attorney” is a person.
“Client” is a person.
“Retainer” is an amount.
“Additional Fees” is an amount.
CLAUSE: Initial Retainer.
Client pays Retainer to Attorney.
CLAUSE: Additional Representation.
Client pays Additional Fees to Attorney.
CLAUSE: End of Representation.
The Attorney may terminate all contracts.

It may feel a bit stilted in terms of “standard” English, but it’s perfectly clear what is meant.

Let’s break down each segment and get you ready to write your own. Lexon has their own test environment, but for the purposes of this tutorial I’m using Remix.

Step one: head into the plugins for Remix:

Nice. Now search for ‘Lexon’ and smash that Activate button:

Now you’ve got a nice little Lexon icon in your tray:

Once you hit that, the Lexon plugin will load, and once you give it writefile access to the file manager, we can start playing. Go up to the ‘file explorers’ icon, the topmost one in the tray, and hit the little ‘plus’ button to create a new file. I’ve named mine ‘retainer.lex’:

Open it up and start drafting! Let’s look at what I coded, step by step:

LEX Retainer Agreement.

You need to give your contract a title, and invoke the Lexon code through the initiating “LEX”. Note the periods — they matter. Next, indicate the version of Lexon you want to use:

LEXON: 0.2.12

You’ve already given it a title, but there’s also a comment section; this is particularly useful if you’re building a boilerplate agreement that will be used, say, with every client, so you can specify names or case numbers, etc:

COMMENT: A boilerplate retainer agreement for legal representation between Jane Doe and Joe Public, Esq.

Great. You’ve got it oriented. Now, what’s the first part of any self-respecting contract? Definitions!

“Attorney” is a person.
“Client” is a person.
“Retainer” is an amount.
“Additional Fees” is an amount.

This is where things get really fun in Remix. By now, the Lexon plugin should be detecting your file and have it ready to compile; in any case, click on the Lexon icon in the icon panel. Now you’ve got your draft on the right-hand side (as the active file in the file editor), and the Lexon plugin on the left. Hit that blue ‘compile’ button and see what happens. If everything’s gone OK, you should get a nice, plaintext-looking copy of your Lexon code. Now, click on the tab labelled “Solidity Code” (in the red here):

Check it out — your Lexon is compiling down to Solidity, and from there down to bytecode, if you wanted to look at it. But let’s stay with the Solidity for a moment. For those of you who know some Solidity (or other languages with similar type declarations), there’s something pretty interesting going on here: we get to see how these definitions translate. A “person” in Lexon is “address payable” in Solidity; and “an amount” is “uint”. Makes sense, and it’s a lot of fun to see what’s going on under the hood.

Ok, we’ve got our parties defined, but what are we going to do with them? Lexon includes functionality in clauses, reminiscent of other natural-language adjacent programming languages:

CLAUSE: Initial Retainer.
Client pays Retainer to Attorney.
CLAUSE: Additional Representation.
Client pays Additional Fees to Attorney.
CLAUSE: End of Representation.
The Attorney may terminate all contracts.

Note that each clause has an identifier; for those of you thinking in machine language, these are functions, and these identifiers are the function names.

So this contract, readable to all of us, compiles to a language that the computer and the blockchain understands, too, and carries out actions between the parties.

Ready to get started? This stuff is bleeding-edge, which means that the functionality I’ve shown here is live, but there are more additions and changes coming. Check out Remix & the Lexon plugin, Lexon’s website, their example code, and the book that explains it all, from linguistic and computer science theory on up.

--

--

mapachurro
Remix Project

Oliver Renwick is a software developer and linguist, a tinkerer and amateur lumberjack. See more of his work at https://www.oliverrenwick.com/#/