Plutus-extra Overview
<u>Data structures</u>
The package introduces PlutusTx.Set of unique values (running in linear time), PlutusTx.Map of key-value pairs, PlutusTx.Bimap of pairs, and PlutusTx.NonEmpty list which always has at least one element.
<u>Plutus Application Backend (PAB) utility functions</u>
Modules in Plutus.PAB directory introduces utility functions to be used with the PAB:
- Plutus.PAB.CurrencyForge exports initCurrency, for minting new currency and giving it to a specific wallet
- Plutus.PAB.OutputBus is a wrapper around the channel transferring information between Contract and real world
- Plutus.PAB.PrettyLogger introduces useful functions for prettying the logs
<u>Type classes</u>
PlutusTx.Bifunctor behaves like a Functor over both of it's type arguments (see attached example diagram below)
<u>Extra functions</u>
The package extends Plutus.V1.Ledger and PlutusTx with useful library functions placed inside modules ending with Extra suffix.
E.g., PlutusTx.Either.Extra introduces function maybeToEither (see attached example diagram below)
The full collection of helper libraries and data structures that compose Plutus-extra and its sub-libraries include:
-plutus-extra: extended functions and data structures for Plutus scripts.
-plutus-numeric: a range of extensions to Plutus' numerical hierarchy.
-plutus-pretty: a collection of helpers for pretty-printing Plutus types.
-tasty-plutus: a testing framework for Plutus scripts.
-plutus-collection: list utility functions that are not present in the Plutus standard library, including functions involving lengths that work with the Natural number type in plutus-numeric, as well as functions related to sorting.
-plutus-context-builder: a utility library for creating ScriptContext with Spending or Minting ScriptPurpose. This provides a builder abstraction for assembling ScriptContext.
-plutus-deriving: a helper for deriving lawful instances of Plutus type classes.
-plutus-golden: a framework for testing serialized representation stability using golden testing. This focuses on type classes used for serialization for Plutus projects.
-plutus-laws: a helper library for checking type class laws, similar in spirit to quickcheck-classes.
-plutus-size-check: a tasty-based utility for checking the on-chain sizes of anything the Plutus compiler can compile.
-quickcheck-plutus-instances: a collection of instances for Plutus types to support general use of QuickCheck.
How does a Plutus helper library support Cardano developers during smart contract development?
In many programming languages helper libraries and utility functions serve as the tooling new developers need to efficiently build and test modular applications. Plutus smart contract development is no different; with an emphasis on property-based testing, performance modeling and script size/resources checks the plutus-extra helper lib becomes a critical piece of infrastructure for the Plutus developer experience.
Similar smart contract utility functions and testing tools on other blockchains have significantly boosted smart contract deployments and developer traction. Ethereum developers use inbuilt functions in Truffle Suite (https://trufflesuite.com/truffle/) to quickly build/test/deploy their contracts.
As early Plutus developers we understand the importance of simple to use tooling for new Cardano smart contract developers, and we are glad to see plutus-extra already in use in some of the ecosystems largest projects. Using this funding to include additional functions requested by Plutus devs interacting with the library, revamp documentation and scale up plutus-extra into an open source product maintained by Cardano ecosystem developers.
Adding the full-time engineering resources needed to develop plutus-extra into a more comprehensive helper library has been the largest challenge to date. Liqwid Labs and MLabs engineers built this library from the combined experience gained developing the Liqwid protocol.