Lexon

Lexon is a contract programming language for lawyers.

Lexon scripts are compiled, in parallel, into legal English language contracts and blockchain smart contracts.

Smart contracts are programs that can move money and resolve automatically. They don't need notaries, judges or attorneys, neither on the happy path nor to resolve edge cases or when the parties disagree about what should happen.

The English text describes precisely what the blockchain contract does. It allows for the smart contract program to be understable by non-programmers and to reason about whether it is legal. These are major roadblocks for the adoption of smart contracts.

The English text also serves as description how to use the smart contract that might be an offer for anyone to enter into, for example a crowd funding offer. The blockchain makes sure that the letters of the contract are exactly fulfilled.

Example

This is a partial example for a crowdfunding contract. The contract allows a benificiary to set a funding goal and deadline. When after the deadline the funding goal is met, the beneficiary will collect the money. Otherwise the funders can withdraw it. This example shows the withdrawal part.

Lexon Script


ARTICLE: WITHDRAWAL.
Comment: This article describes how collected funds can be withdrawn.

SECTION 1: a funder wants to withdraw. 
IF WITHDRAWAL BY FUNDERS ALLOWED AND
   REQUESTER'S BALANCE GREATER THAN 0, THEN:
        TRANSFER REQUESTER'S BALANCE TO REQUESTER; AND
        IF THIS TRANSFER SUCCEEDS, THEN:
                RECORD: 'FUND TRANSFER', REQUESTER, BALANCE; AND
                SET REQUESTER'S BALANCE 0.

SECTION 2: the beneficiary wants to pick up the funds.
IF REQUESTER IS BENEFICIARY, AND
   SUM OF FUNDS GREATER OR EQUAL FUNDING GOAL, AND
   FUNDING DEADLINE PAST, THEN:
        TRANSFER AMOUNT RAISED TO BENEFICIARY; AND
        IF THIS TRANSFER SUCCEEDS, THEN:
                RECORD: 'FUND TRANSFER', BENEFICIARY, AMOUNT RAISED; 
        OR ELSE
                ALLOW WITHDRAWAL BY FUNDERS.

The above Lexon script is compiled into the following two results.

This is the legal English text:

Legal English



And this is the smart contract to be executed on the blockchain, namely Solidity code for Ethereum.

Smart Contract


function withdrawal() {

        if (funderWithdrawalsAllowed 
                && balanceOf[msg.sender] > 0) {
                bool ok = msg.sender.send(balanceOf[msg.sender]);
                if (ok) {
                        FundTransfer(msg.sender, balanceOf[msg.sender], false);
                        balanceOf[msg.sender] = 0;
                }
        }

        if (beneficiary == msg.sender 
                && amountRaised >= fundingGoal 
                && now >= deadline) {
                bool ok = beneficiary.send(amountRaised);
                if (ok) {
                        FundTransfer(beneficiary, amountRaised, false);
             } else {
                        funderWithdrawalsAllowed = true;
                }
        }
}

NOTE: This example is a draft. The logic is not complete and not hardened.

Page optimized for viewing w/lynx 1.0