Contracts and Trust

Two nights ago, I was convinced to watch 50 Shades of Grey. Not the whole movie, thank god, just the contract negotiation scene.

I don’t get it, I said. Two adults are about to engage in sexual relations. Why do they need a contract? Don’t they trust each other? And if they don’t trust each other, why don’t they walk away?

The same question applies to pre-nups. Or even the institution of marriage! Unless one party poses a significant flight risk, why would willing participants need a legal contract to compel each other to stay?

To better understand this, let’s start with a simpler contract.

Loan contracts.

Suppose you apply for a mortgage with the best of intentions. The loan is approved thanks to your impeccable credit score and 10% down. It’s a large mortgage, but your salary is five times the monthly payment so you should pay it off no problem.

Fast-forward half a decade. The housing market has collapsed, your dog needs kidney dialysis, and to top it all off, a robot just took your job.

How motivated are you to continue paying that mortgage?

While you may be a trustworthy individual at time of loan application, it’s future-you that can’t be trusted. As long as the cost of defaulting on the contract (loss of home equity) is greater than the opportunity cost of mortgage payments, repayment can be coerced.


Much like a consumer loan agreement, marriage is an institution founded on mistrust. Sure, things are going great right now, but it is a cruel fact of nature that most humans do not age well.

What will compel you to stick around after she doubles in size and succumbs to the effects of gravity? And what happens after you become a balding couch ornament with the gut of a ruminant?

This is why marriage contracts were invented. Conjugal bliss can exist when both parties follow similar rates of decay, but this symmetry is rare. Discord arises when one party decays more rapidly than the other. Or, worse, when one party’s income substantially increases.

If the cost of terminating the marriage is less than the opportunity cost of remaining in the contract, it is inevitable that the contract will be breached. The key to a successful marriage is to ensure a sufficiently high cost of termination for both parties. Like, always keep a few thermonuclear warheads up your sleeve.

Back to 50 Shades.

If I understand correctly, the entire movie is about the process of contract negotiation. Christian Grey needs to protect himself from legal recourse if Ana decides to sue him for excessive shenanigans.

As a result, they arrive at an overly complex agreement detailing every possible activity or instrument that could possibly be employed. There’s an easier way.

Christian and Ana’s many pages of complexity can be reduced to a simple smart contract. Here’s how it works:

Each participant puts a valuable consideration (say, 10 ether) into escrow. The participants wear GPS tracking devices that continuously relay their location coordinates to the contract.

Just like in the movie, Ana has two safe words, yellow and red. After the first safe word is invoked, Christian has 10 minutes to move at least 1000 feet away from Ana. If the second safe word is invoked, and the contract detects that Christian is still within the stay-away radius, Ana gets all the money. If Christian is outside the radius and the red safe word is invoked, then Ana is being dishonest about her safety and Christian gets all the money.

Here’s a template, now all they have to do is put it on the blockchain.

import "math.sol";

contract FiftyShades {
    address dominant;     // contract participants
    address submissive;

    uint public value;    // deposit value
    uint public distance; // distance between dom and submissive

    int subCoordX;  // cartesian coordinates 
    int subCoordY;  // of participants
    int domCoordX;
    int domCoordY;

    // contract state. 
    // Green = no safe words yet.
    // Yellow = first safe word, Red = second safe word
    enum State { Dormant, Green, Yellow, Red }
    State public state;

    // when was first safe word used?
    uint public yellowStartTime;

    // submissive creates the contract
    function FiftyShades(int subCoordX_, int subCoordY_) {
        submissive = msg.sender;
        value = msg.value;      // submit deposit
        subCoordX = subCoordX_; // initialize location
        subCoordY = subCoordY_;
        state = State.Dormant;

    // contract becomes active when dominant submits deposit
    function addDeposit(int domCoordX_, int domCoordY_) {
        // require an equal contribution
        if (msg.value < value) throw;

        dominant = msg.sender;
        domCoordX = domCoordX_; // init location
        domCoordY = domCoordY_;
        // deposits received, ready to go
        state = State.Green;

    modifier onlySubmissive() {
        if (msg.sender != submissive) throw;

    modifier onlyDominant() {
        if (msg.sender != dominant) throw;

    modifier inState(State _state) {
        if (state != _state) throw;

    event aborted();  // cancel contract
    event yellowState();  // first safe word used
    event redState();     // second safe word used
    event falseAlarm();

    /// First Safe word used by submissive
    /// After first safe word, the dominant has 10 minutes
    /// to move at least 1000 feet away from the submissive
    function safeWordYellow(int subCoordX_, int subCoordY_)
        subCoordX = subCoordX_;  // record location
        subCoordY = subCoordY_;
        yellowStartTime = now;   // record start time
        state = State.Yellow;

    /// Second safe word used by submissive
    function safeWordRed(int subCoordX_, int subCoordY_)
        // has enough time elapsed?
        if (now >= yellowStart + 10 minutes) {
            state = State.Red;
            // TODO: check submissive's movement since last safe word
            // Ensure that submissive is not chasing after dominant
            subCoordX = subCoordX_;
            subCoordY = subCoordY_;

            // calculate distance beteen dominant and submissive
            distance = calcDistance();
            // is the dominant outside of the stay-away distance?
            if (distance < 1000) {
                paySubmissive();  // no: pay submissive 
            } else {
                payDominant();    // yes: submissive misused the safe word

    function paySubmissive()
        suicide(submissive); // kill contract, everything goes to submissive
    function payDominant()
        suicide(dominant); // kill contract, everything goes to dominant
    /// Can only be called by the submissive
    /// before dominant deposit
    function abort()
        suicide(submissive); // kill contract, return initial deposit to submissive

    function updateDomLocation(int domCoordX_, int domCoordY_)
        domCoordX = domCoordX_;
        domCoordY = domCoordY_;

    function updateSubLocation(int subCoordX_, int subCoordY_)
        subCoordX = subCoordX_;
        subCoordY = subCoordY_;

    //pythagorean distance
    function calcDistance() returns (uint d) {
        int x = subCoordX - domCoordX;
        int y = subCoordY - domCoordY;
        int dist = Math.sqrt(x*x - y*y)
        return dist;

    /// TODO: use Haversine distance, add trig fxns to Math lib

    function() {

For comparison, here is the 10-page entanglement the characters used in the movie.

7 thoughts on “Contracts and Trust

    1. ooh, good poinT–WAIT, he has a skyscraper and helicopter, and she’s sitting here whining about duct tape and butt plugs?

Leave a Reply