Technical Overview: Plutus Architecture

Since you’re here, you’ve probably heard of Cardano. If you’ve been here for a while, you might know what a “smart contract” is. Here is something that still isn’t well-known to many: Plutus. Drawing from a video published to IOG’s YouTuve channel in April, this article describes what Plutus is and its importance in the Cardano architecture.

The foundation of the Cardano blockchain platform is built on two separate layers: A Cardano Settlement Layer (CSL) and a Cardano Computation Layer (CCL). Plutus is a range of technologies powering the CCL :

  • Plutus is at the core of Cardano’s smart contract platform that powers the creation of DApps (decentralized applications).
  • Plutus enables non-fungible tokens (NFTs) which have been very popular this year.
  • Plutus is how you launch native assets on Cardano: the ability for you to create your own coin or currency.
  • Finally, Plutus allows arbitrary on-chain conditional logic: imagine excel-style “if”-statement programmability, but on the Cardano blockchain.

At the heart of how the Plutus platform components function is something called EUTxO.

First, “UTxO” stands for “Unspent Transaction Output’; it’s the name for the “cash drawer” model of accounting pioneered by Bitcoin. In this model, values of varying amounts are stored in UTxOs, like the way you might put bills of different values in a cash drawer. You can also think of a UTxO as wrappers for one or more ADA on the Cardano blockchain.

The “E” at the beginning of EUTxO stands for “Extended”: EUTxO is how Cardano does on-chain programmability and smart contracts. There are four components of EUTxO: Contract, Redeemer, Datum, and Context.

Contract: Smart Contracts are programs, stored on the blockchain, that run when pre-set conditions are met. They can be thought of as locks that hold UTxOs. You can also think of smart contracts as validators or simply a programming script.

Redeemer: This is the data passed from the user to the smart contract. In a simple UTxO, a redeemer could be a signature which provides proof of ownership of the UTxO and access to the contents. You can think of the redeemer as a key to unlock a contract.

Datum: A piece of information that can be associated with a UTxO. It is used to store script state information such as its owner or the timing details (which define when the UTxO can be spent). You can think of Datum as the hard drive for a smart contract, for storing all kinds of data.

Context: Context is essentially the summary or metadata of the transaction. It can include information such as who signed for the transaction or where the funds are going.

With these four components of EUTxO, the Plutus platform allows businesses and developers to develop a wide range of decentralized applications, financial products, and games on Cardano.

The Plutus Platform

The Plutus Platform starts with developer code, then goes through a series of optimization steps, and finally gets put on chain (the ledger api) and ultimately executed and run by the plutus core evaluator in a decentralized way.

Source Code

Plutus starts with programming code on a developer’s computer, before that code reaches the blockchain and before users come into the picture. As of this writing, all Plutus contracts are written either in the Haskell programming language, or supersets of Haskell. Confusingly enough, Plutus itself is also a programming language, a superset of Haskell that makes writing Haskell less laborious and reduces boilerplate. The Plutus platform is designed to support other languages or domain-specific languages in the future to make it easier for certain uses, but at the moment, Plutus and Haskell is your only option.

Compiler Pipeline

After a developer crosses the I’s and dots their T’s, the Haskell script is converted to Plutus IR. Plutus IR is an “Intermediate Representation” of the Haskell code. This IR state is not quite 1s and 0s machine code yet, but rather an opportunity for Plutus to optimize the developer’s code for the most efficient 1s and 0s output. Plutus IR is to Cardano development what LLVM is to Apple iOS apps development or the Rust programming language.

From Plutus IR, the code is turned into typed-Plutus core. This is just before the raw 1s and 0s. It provides a low level layer to help developers spot issues easily before entire 1s and 0s land.

Next up is untyped-Plutus Core–a lambda calculus variant, a way to express the app in pure logic (see link at the bottom for wikipedia article). This Untyped Plutus core representation of the app is what will get executed on the blockchain.

Getting On-Chain

After all of the optimization, the compiled app is finally ready to get ‘deployed’ or injected on the blockchain. In Cardano, there are other Plutus apps to help with this as well as developer toolkits.

Off-chain code

Once your code is on the blockchain, you will need to write another set of Plutus/Haskell code to support transaction generation. This off-chain component of your app is the part that will correctly gather things like the redeemer and the datum and build a transaction that can interact with the compiled code living on the blockchain.

Conclusion

With your compiled onchain code and your off-chain code, your DApp is ready to facilitate user interactions. The next installment in this series will go in depth about Plutus Interactions.

Related Links

  • Lambda calculus writeup wikipedia
  • Cardano Technical Briefing: Plutus by John Woods video

Get more articles like this in your inbox

What is your experience with the Plutus platform? What still puzzles you?

Or leave comment
Share

No comments yet…

avatar
You can use Markdown
close

Playlist

  • EP2: epoch_length

    Authored by: Darlington Kofa

    3m 24s
    Darlington Kofa
  • EP1: 'd' parameter

    Authored by: Darlington Kofa

    4m 3s
    Darlington Kofa
  • EP3: key_deposit

    Authored by: Darlington Kofa

    3m 48s
    Darlington Kofa
  • EP4: epoch_no

    Authored by: Darlington Kofa

    2m 16s
    Darlington Kofa
  • EP5: max_block_size

    Authored by: Darlington Kofa

    3m 14s
    Darlington Kofa
  • EP6: pool_deposit

    Authored by: Darlington Kofa

    3m 19s
    Darlington Kofa
  • EP7: max_tx_size

    Authored by: Darlington Kofa

    4m 59s
    Darlington Kofa
0:00
/
~0:00