Explore Legal.io

For Clients
Legal.io company logo
Hire Talent
Find the best fit for any legal role
For Members
Jobs
The best legal jobs, updated daily
Salaries
Benchmark compensation for any legal role
Learn
Learn and grow with our community
Events
Connect with peers at exclusive events
Apps
Tools to streamline legal work
Advertise on Legal.io
Post a job for free
Reach more qualified applicants quickly
Advertise with Us
Reach a targeted audience

For Clients

Hire Talent
Legal.io company logo
Solutions
Find the best fit for any legal role
New Hire
Get highly qualified candidates in days
Popular Roles
Data & Tools
Budget Calculator
Plan and manage your legal budget
Salary Insights
Compensation data for legal roles
Vendor Directory
The ultimate list of legal tech tools

What is a Smart Contract?

A smart contract is a computer protocol intended to digitally facilitate, verify, or enforce the negotiation or performance of a contract. This guide explains what smart contracts are, and discusses some of their proporties as well as the legal challenges surrounding this new type of agreement.

What is a Smart Contract?

What are smart contracts?

A "smart contract" is a computer protocol intended to digitally facilitate, verify, or enforce the negotiation or performance of a contract. Smart contracts allow the performance of credible transactions without third parties. These transactions are trackable and irreversible.

Smart contracts enable parties to exchange money, property, shares, or anything of value in a transparent way while avoiding the services of a middleman. One way to think about smart contracts is by comparing then to vending machines. With smart contracts, you send bitcoin (or an altcoin) into the vending machine (i.e. the blockchain), which allows the contract to execute. For example, the contract could hold your cryptocurrency in escrow or automatically release it to a beneficiary if certain conditions are met. Often, smart contracts will require other parameters (e.g. information around the beneficiary of a transaction) to execute.

Not only can smart contracts define the rules and penalties around an agreement in their code, they also create the potential of automatically enforcing those obligations. Because smart contracts live on the blockchain, users of the contract can inspect the code and familiarize themselves with the rules, functions and limitations of the contract. A list of example smart contracts can be found at www.stateofthedapps.com

It's worth noting at the outset that the legal framework around smart contracts is emergent, and that many questions around jurisdiction, the legality and enforceability of smart contracts remain unanswered.

Smart contracts: an example

The below is an example of a smart contract written in Solidity, the programming language for the Ethereum virtual machine. The code below is annotated, explaining the different functions of the code.

  

pragma solidity ^0.4.11;

contract SimpleAuction {
    // Parameters of the auction. Times are either
    // absolute unix timestamps (seconds since 1970-01-01)
    // or time periods in seconds.
    address public beneficiary;
    uint public auctionEnd;

    // Current state of the auction.
    address public highestBidder;
    uint public highestBid;

    // Allowed withdrawals of previous bids
    mapping(address => uint) pendingReturns;

    // Set to true at the end, disallows any change
    bool ended;

    // Events that will be fired on changes.
    event HighestBidIncreased(address bidder, uint amount);
    event AuctionEnded(address winner, uint amount);

    // The following is a so-called natspec comment,
    // recognizable by the three slashes.
    // It will be shown when the user is asked to
    // confirm a transaction.

    /// Create a simple auction with `_biddingTime`
    /// seconds bidding time on behalf of the
    /// beneficiary address `_beneficiary`.
    function SimpleAuction(
        uint _biddingTime,
        address _beneficiary
    ) public {
        beneficiary = _beneficiary;
        auctionEnd = now + _biddingTime;
    }

    /// Bid on the auction with the value sent
    /// together with this transaction.
    /// The value will only be refunded if the
    /// auction is not won.
    function bid() public payable {
        // No arguments are necessary, all
        // information is already part of
        // the transaction. The keyword payable
        // is required for the function to
        // be able to receive Ether.

        // Revert the call if the bidding
        // period is over.
        require(now <= auctionEnd);

        // If the bid is not higher, send the
        // money back.
        require(msg.value > highestBid);

        if (highestBidder != 0) {
            // Sending back the money by simply using
            // highestBidder.send(highestBid) is a security risk
            // because it could execute an untrusted contract.
            // It is always safer to let the recipients
            // withdraw their money themselves.
            pendingReturns[highestBidder] += highestBid;
        }
        highestBidder = msg.sender;
        highestBid = msg.value;
        HighestBidIncreased(msg.sender, msg.value);
    }

    /// Withdraw a bid that was overbid.
    function withdraw() public returns (bool) {
        uint amount = pendingReturns[msg.sender];
        if (amount > 0) {
            // It is important to set this to zero because the recipient
            // can call this function again as part of the receiving call
            // before `send` returns.
            pendingReturns[msg.sender] = 0;

            if (!msg.sender.send(amount)) {
                // No need to call throw here, just reset the amount owing
                pendingReturns[msg.sender] = amount;
                return false;
            }
        }
        return true;
    }

    /// End the auction and send the highest bid
    /// to the beneficiary.
    function auctionEnd() public {
        // It is a good guideline to structure functions that interact
        // with other contracts (i.e. they call functions or send Ether)
        // into three phases:
        // 1. checking conditions
        // 2. performing actions (potentially changing conditions)
        // 3. interacting with other contracts
        // If these phases are mixed up, the other contract could call
        // back into the current contract and modify the state or cause
        // effects (ether payout) to be performed multiple times.
        // If functions called internally include interaction with external
        // contracts, they also have to be considered interaction with
        // external contracts.

        // 1. Conditions
        require(now >= auctionEnd); // auction did not yet end
        require(!ended); // this function has already been called

        // 2. Effects
        ended = true;
        AuctionEnded(highestBidder, highestBid);

        // 3. Interaction
        beneficiary.transfer(highestBid);
    }
}

Deploying a smart contract

In order to deploy a smart contract to the (in this case, Ethereum) blockchain, the writer of the contract will need to compile the contract to bytecode and pay a gas fee to see it go live on the network. Typically, contracts are first tested on a test network, so that the functionality of the contract can be verified without spending tokens that represent real value. 

The below screenshot shows an example of the Ethereum Wallet, an application that allows for the deployment of smart contracts to the Ethereum blockchain. As you can see to the right of the screenshot, the smart contract requires a number of variables (in this example, the time the auction as defined by the contract will be active, as well as the beneficiary of the eventual proceeds of the auction.

Ethereum Wallet

Once a contract is deployed to the blockchain, it is immutable, meaning that it cannot be changed (unless the contract specifically provides for such changes, e.g. through a kill switch).

Legal.io Logo
Welcome to Legal.io

Connect with peers, level up skills, and find jobs at the world's best in-house legal departments

More from Legal.io

How to Handle Gaps on Your Resumé

If you’ve spent time out of work, the resulting gap on your resumé can feel like a yawning chasm. But if you handle it right, this needn’t be the case. The most common reasons for taking time out are parenthood, illness, being laid off or fired, caring for family, study, travel, or time to think. Fortunately, any of these can be framed positively – it’s simply a matter of finding the right way to present your time. Here are some ideas for ensuring that gap doesn’t hold you back.

How to Handle Gaps on Your Resumé
Career
Law Firms Divided on AI Impact on Legal Jobs

Most law firms are taking steps to ensure they capitalize on the rapid advancements in AI, but have different views on how the technology will impact legal jobs in the next five years, a survey shows.

Big Law Gears Up for Anticipated SEC Overhaul

Big Law firms anticipate more work in capital markets and cryptocurrency as the new U.S. administration shifts SEC priorities and eases regulations.

Big Law Gears Up for Anticipated SEC Overhaul
Amy Fisher Appointed as General Counsel of The Port Authority of New York and New Jersey

She was promoted to GC of The Port Authority of New York and New Jersey after six years of in-house work within the company and several decades legal experience.

Amy Fisher Appointed as General Counsel of The Port Authority of New York and New Jersey
General CounselCareer
Community Spotlight: Jessica Vander Ploeg, Senior Director of Legal Ops at Micro Focus

Join our host and CEO, Pieter Gunst, as he dives into the career journey of Jessica Vander Ploeg, VP, Legal Operations at Micro Focus.

Community Spotlight: Jessica Vander Ploeg, Senior Director of Legal Ops at Micro Focus
Legal OperationsSpotlight
BriefCatch Secures $3.5M Seed Round for Expansion and Inclusion of AI Features

LawCatch Inc., the company behind BriefCatch legal editing software, has successfully raised $3.5 million in an oversubscribed seed round of funding. The lead investor in the funding round was TIA Ventures (www.tiaventures.com), and other notable participants included RiverPark Ventures, C2 Ventures, and Wilson Sonsini Investments Co. This investment round enables TIA Ventures to take a seat on LawCatch's board as well.

Newsletter
How do I properly use third-party copyrighted content in my video or stream?

Learn how to properly use third party content in your videos or stream and protect your channel against muting, takedowns, and lawsuits.

CopyrightIntellectual Property
May 12, 2023 Edition #158

Published weekly on Friday, the Legal.io Newsletter covers the latest in legal, talent & tech

May 12, 2023 Edition #158
Newsletter
Legal.io Logo
Welcome to Legal.io

Connect with peers, level up your skills, and find jobs at the world's best in-house legal departments