Ripple Labs is thrilled to announce the publication of Smart Oracles, a white paper that describes a novel, simple, and flexible approach to smart contracts.
In such a system, rules can be written in any programming language, and contracts can interact with any service that accepts cryptographically signed commands. The paper also includes our implementation of smart oracles, called Codius (based on the Latin “ius” meaning “law”).
Smart contracts are an exciting new frontier for technology, business, and law that have the potential to usher in a wave of innovation and serve as a building block for a next chapter of the internet.
What’s a smart contract?
The concept of smart contracts is widely attributed to Nick Szabo who, in the late 1990s, argued that formalizing relationships and encoding them in software and hardware would simplify and secure business logic and functionality.
[O]ur institutions still take for granted that we live in a world of paper. We formalize our relationships with written contracts, written laws, and forms designed for paper […] Smart contracts reduce mental and computational transaction costs imposed by either principals, third parties, or their tools. The contractual phases of search, negotiation, commitment, performance, and adjudication constitute the realm of smart contracts. —Nick Szabo, Formalizing and Securing Relationships on Public Networks (1997)
Szabo wrote of embedding contractual clauses, such as bonds and property rights. He used the example of the vending machine as a “primitive ancestor” of smart contracts because its hardware and software enforce a simple contractual agreement. Anyone who inserts money will receive a snack in return, even though no explicit contract was ever made with the machine’s owner.
As defined by the Cornell Legal Information Institute, a contract is “an agreement creating obligations enforceable by law.” Most contracts—like an automobile lease or an employment agreement—can be distilled to a set of predetermined conditions and possible outcomes.
The concept of a smart contract is to formally encode these conditions and outcomes into a computer program. Rather than rely on another party to enforce the terms of the arrangement, the obligations of a smart contract are settled automatically and autonomously through the execution of its code. As such, math-based currency networks like Bitcoin and Ripple provide an important building block for smart contracts by allowing the transfer of digital assets with a cryptographic signature.
The benefits of using smart contracts instead of traditional contracts are increased speed, efficiency, and trust that the contract will be executed exactly as agreed.
What’s a smart oracle?
Most proposals for smart contracts depend on independent entities to inform contracts about the state of the outside world. Bitcoin contracts rely on “oracles” to attest to facts from the outside world by introducing signatures into the network if and only if specific conditions are met. For instance, the smart contract for a will would need to know whether or not someone had died.
Such a system typically requires the smart contract code to be executed on the consensus network itself. But encoding advanced logic and executing untrusted code is complicated to integrate. Until now, this has been one of the primary obstacles for creating a viable smart contract system.
Smart oracles take the concept of oracles a step further by placing the untrusted code execution in the oracles’ hands. Smart oracles, then, are trusted or semi-trusted entities that can both provide information about the outside world and execute the code to which the contracting parties agreed.
By decoupling the execution of untrusted code from the consensus databases and other services that track and transfer asset ownership, smart contracts can be achieved without increasing the complexity of existing consensus networks like Bitcoin and Ripple.
Without being tied to any single consensus network, contracts created using smart oracles can interact with multiple networks at once as well as virtually any type of online service. This means that a single smart contract could interact with Bitcoin and Ripple, web-based services like PayPal, Google, Ebay, etc. or even other Internet protocols, such as SSH, LDAP, SMTP and XMPP.
The most basic implementation of smart oracles involves only one oracle. The oracle is trusted to execute code properly, and the participants must have faith that it will not disappear with any assets the contract controls or collude with any of the contracting parties.
Many companies today offer to run code for other businesses and individuals, and are trusted to do so. The single trusted host model is similar to internet hosting services and software as a service (SaaS) providers.
Smart oracles can also be implemented using a multiple host model, which may be better suited for certain situations, such as scenarios that involve high value or low trust.
Smart contracts with Codius
The Codius implementation of smart oracles is designed to provide developers with a robust and familiar platform to build smart contracts and hit the ground running. Because Codius uses Google’s Native Client to sandbox untrusted code, developers can write contracts in any programming language.
Codius and smart oracles in general open up new possibilities for developers, entrepreneurs, and enterprising legal and financial professionals. Agreements that previously required lengthy legal contracts can be translated into code and run automatically by smart oracles.
Smart contracts hold the potential to empower people to build a fairer, more affordable and more efficient legal system and smart oracles are one of the simplest ways to realize that dream.
Potential use cases:
- Bridges between value networks. Distributed networks like Bitcoin and Ripple maintain separate ledgers or blockchains that track accounts and balances. Traditional financial systems have their own ledgers as well. Contracts built on smart oracles can create automatic and fully trustworthy bridges between disparate systems. Such a bridge could accept payments in one system and immediately issue a balance or initiate a payment in another.
- Escrow. Smart contracts can easily be set up as escrow accounts that monitor an exchange between two people.
- Cryptocurrency wallet controls. Currently Bitcoin and Ripple have no good mechanism for enabling pull payments, where the seller can initiate a payment on behalf of the buyer in the way that credit and debit cards do. Wallets controlled by contracts could include many different types of complex controls, from daily withdrawal limits to granting and revoking access for specific entities. This would enable subscription and conditional payments, and granular controls over wallet access without disclosing the private key.
- Auctions for digital assets. A smart contract can trivially carry out the rules for an auction if it is given ownership over a digital asset or title.
- Derivatives. Contracts that monitor the performance of digital or non-digital assets can also be used as futures, forwards, swaps, options.
- Debt and equity. Other securities based on payments and rights that are carried out according to predefined rules can also be written as smart contracts.
- Smart property. The classic example of smart property is a car that knows who its owner is based on a transferable but non-forgeable digital token. Contracts can be set up to govern the transfer of ownership and accompanying rules.
- Voting. In the future smart contracts can be used to enforce democratic, bureaucratic, and other types of control structures over assets or even organizations.
Since the system is so extensible, the functionality will continue to expand as the ecosystem develops. Want to get involved? Join the community! Visit www.codius.org.