Programming for the future with Plutus

Cardano for the Masses: Age of Voltaire Edition Read-along

We’re reading the latest edition of Cardano for the Masses: the Age of Voltaire by John Greene, and want to encourage community participation by doing a read-along. We invite you to pick up the book, come along, leave a comment, and participate in the related “Every Epoch” giveaway when they come up!

In Chapter 6 of Cardano for the Masses, this reader took a deep breath before diving into a 30 page exploration of Cardano’s smart contract programming language, Plutus. A “real programmer” (I am not) will doubtless understand more of this chapter than I did. However I believe that anyone with an interest in Cardano can learn valuable things by touring the full landscape. Aside from a cryptic quote on the chapter’s opening page about gold, the author didn’t address my burning question, which was “Why is it called Plutus?” So I googled it myself and learned that Plutus is the Greek god of wealth. With that out of the way, what did author Greene have to say about Plutus?

First came a helpful clarification; Cardano’s code is written in Haskell. Cardano has not one but two programming languages that have been created to work with it: Plutus and Marlowe. Both of these programming languages are based on Haskell.

Marlowe is a “domain-specific” language. Domain-specific simply means (I googled this too) that the language was developed and optimized to deal with a specific set of concerns. Marlowe was developed for building financial contracts - specifically and exclusively.

Plutus, then, is the other one. It is the primary coding language for writing DApps of all kinds that interact with Cardano. With Plutus you can build oracles, Decentralized Exchanges (DEXs), lending protocols, NFT functions, stable coins, and more! Plutus is in fact more than just a language. It is a platform, consisting of the language itself, “Plutus Core”, the “Plutus Application Framework,” which enables app-building, and the “Plutus Application Backend,” which handles the off-chain elements of an application.

Plutus, we learn in this chapter, offers some advantages when compared with other programming languages in the blockchain context. Plutus makes it simpler to know and demonstrate that your smart contract is secure. Some chains use different programming languages for different things, while in Cardano it’s Haskell-based programming all the way through. Haskell might not be the easiest language, but working from a single common code base offers advantages, ultimately. Plutus enables “user-defined tokens” in a way that requires much less code than Ethereum. Finally, not to bury the lead, is that Plutus offers predictability. This means that a user can know if a transaction is valid and what the fee will be before submitting the transaction. As someone who has primarily used Cardano, I confess I take this for granted. The .17 ada I typically see as a transaction charge isn’t nothing, but it’s so negligible that it never prevents me from participating. Compare this to Ethereum, where “gas” fees for a transaction can’t be predicted and can range from a few dollars to hundreds of dollars! Suddenly, predictable Plutus looks good indeed.

The chapter also covers some basics of how Plutus works, with more about EUTXOs, and introductions to the concepts of Datum, Context, and Redeemer, and the role they play in transactions. It also walks through some of the changes to Plutus as they correspond to the evolving Cardano eras and roadmap. This is a reminder that nothing in software is ever settled for good, but rather that any healthy software is always being built forward toward the next big thing.

One feature of Cardano’s transaction functions that clicked for me on this reading was the concept of collateral in a transaction. I’ve turned on the collateral function in my own wallet, because it was required in order to do fun things like buy an NFT, but I didn’t actually understand what it was there for. Chapter 6 explains that collateral is there to prevent careless or malicious actors from running badly-written transactions that are bound to fail. When a transaction works as expected, all the user will pay is the expected transaction fee, which is usually very low. However, if a transaction fails after the network has already gotten to work on it – that incurs a cost. Node operators doing that work have to get paid! If that happens, the user will lose their collateral. Collateral is not usually set to a really large amount - mine is set at 5 ada. However, if a bad actor wanted to really gum up the system by submitting loads of bad transactions – that collateral penalty would add up fast. In that way, collateral prevents that kind of network attack by simply making it too expensive.

One of the biggest values in the chapter may be its wide-ranging aggregation of resources for aspiring Plutus developers to learn, hone, and exercise their craft. The following is an incomplete list; both the text and footnotes are chockablock with links and references to the many pillars that support the ecosystem.

  • Plutus Pioneers: This is the training program for Plutus developers created by IOG. Aspiring Plutus developers can apply for a spot as future cohorts are offered. It’s not for beginners, but is a great option for seasoned developers looking to skill up in Cardano.
  • Plutus Playground: a place where smart contracts may be written and tested.
  • Plutus Application Backend: This feature was intended to deliver a “Sandbox”-like environment that allows developers to test DApp features, along with a library of resources to simplify the building on their local machines without having to set up servers and lots of expensive infrastructure. In this edition of the book, the PAB features prominently, but my efforts to find it online were stymied. That search led to the latest intel, which is that another team was able to successfully deliver on the intended PAB features →
  • Atlas: “An all-in-one open-souce solution to build on Cardano.” I’ll leave it at that since we are now venturing beyond this chapter of the book, but check out Atlas for all your “PAB” needs!
  • Plutus Fee Estimator: This does just what it says. Developers can test the DApps they are building to see what transaction fees are likely to be before launching a DApp, or to check how future updates will affect costs.
  • Cooked Validators: A library of resources for easily stress-testing your DApp code h
  • GimbaLabs: This is my own insertion, as I don’t remember seeing it in this chapter. But if we are listing resources for learning Plutus, I can’t imagine leaving out our friends at GimbaLabs. Their PPBL course and weekly “Gimbalabs playground” meeting offers a self-paced “Plutus Project Based Learning” curriculum and a friendly weekly meeting to meet fellow learners and work together.
  • Community Support: If you want to warm up to a potential crack at Plutus Pioneers, or just get your feet wet, there’s lots of community resources out there. Chris Moreton @ChessPool transcribed the Plutus Pioneer program lecture notes, and they look amazing. Oussama Benmahmoud wrote “How to prepare for the Plutus Pioneer Program.” There is a YouTube course called “Haskell and Crypto Mongolia” taught in part by the then education director at IOG. These are just a few named in the book, and it’s likely that community-driven resources are ever growing and evolving online. The Cardano Forum is a good place to ask questions about specific resources, or the latest favorites.
  • Getting its own shout-out just because I ordered myself a copy on Amazon: “Learn You a Haskell for Great Good” is actually available to read for free online. http://learnyouahaskell.com/ I was sucked in by the friendly cartoon elephant and rainbow graphics on the cover, the quirky title (it’s not a typo!), and the Amazon reviews, many of which noted it was the first programming book they ever read cover-to-cover.

Before concluding this episode of our read-along, I think it should be mentioned that it is not necessarily the case that any developer wishing to work in Cardano needs to learn Haskell, or Plutus. This chapter is about Plutus and the important role it plays, and certainly it’s a valuable skill to have in the Cardano world. However, just as the Cardano community puts a high value on its blockchain becoming interoperable with other chains, so too do the developers see the high value of making DApp development interoperable with other programming languages. The “Developer Experience” department at IOG is focused on providing continuous improvements and tooling for app builders on Cardano. This includes tools that make Haskell programming more accessible. It also includes efforts to make it possible to code for Cardano in other common programming languages. The effort to make programming interoperable isn’t just up to the bigwigs at IOG either; various contributors have created other third party alternatives that allow users to write code in TypeScript (plu-ts), Javascript, Python (opshin), Rust (aiken)… and the list goes on. These and other options, along with links, can be found in this chapter.

For you who are beginners or experts learning and using Plutus - what resources were most helpful to you as you started your journey?

Related Links

  • Plutus Playground Website
  • Atlas Website
  • Cardano Smart Contracts + Languages Website
  • Learn You a Haskell for Great Good Website
  • Plutus Project Based Learning - Gimbalabs Website
  • Cooked Validators Website
  • Plutus Fee Estimator Website
  • Relevant Link 3 link

Get more articles like this in your inbox

Was the article useful?

Or leave comment
Share
Commenter avatar

thanks for the review….the naming of Plutus was explained in an earlier chapter!

avatar
You can use Markdown
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