Skip to main content

Plutus

info

To start developing with Plutus, see:

Plutus is the native smart contract language for Cardano. It is a Turing-complete language written in Haskell, and Plutus smart contracts are effectively Haskell programs. By using Plutus, you can be confident in the correct execution of your smart contracts. It draws from modern language research to provide a safe, full-stack programming environment based on Haskell, the leading purely-functional programming language.

Plutus smart contracts

Plutus smart contracts consist of parts that run on the blockchain (on-chain code) and parts that run on a user’s machine (off-chain or client code). Off-chain code can be written using the Plutus Application Framework (PAF), and this code is then compiled by the GHC (Glasgow Haskell Compiler), whereas on-chain code is compiled by the Plutus compiler into Plutus Core.

Accounting model used by Plutus

Cardano uses the extended UTXO accounting model (EUTXO) which extends the unspent (U) transaction (TX) output (O) accounting model (UTXO) (used by Bitcoin). In the UTXO model, a transaction has inputs and outputs, where the inputs are unspent outputs from previous transactions. As soon as an output is used as input in a transaction, it becomes spent and can never be used again. The output is specified by an address (a public key or public key hash) and a value (consisting of an ada amount and optional, additional native token amounts).

EUTXO extends the UTXO model by allowing output addresses to contain complex logic to decide which transactions can unlock them, and by adding custom data to all outputs. This model offers unique advantages over other accounting models. The success or failure of transaction validation depends only on the transaction itself and its inputs and not on anything else on the blockchain. Consequently, the validity of a transaction can be checked off-chain before the transaction is sent to the blockchain. A transaction can still fail if some other transaction concurrently consumes an input that the transaction is expecting. However, if all inputs are still present, the transaction is guaranteed to succeed.

Plutus Core

Plutus Core is the scripting language used by Cardano to implement the EUTXO model. It is a functional language similar to Haskell, and a large subset of Haskell can be used to write Plutus Core scripts. As a smart contract author, you don’t write any Plutus Core; rather, all Plutus Core scripts are generated by a Haskell compiler plugin.

These scripts will be executed by nodes during transaction validation ‘live’ on the chain. They will either lock EUTXOs in the form of validator scripts or as minting policies, which control the minting and burning of native tokens.

In practice, when developing smart contracts, you will write validator scripts in Haskell, which will then be automatically compiled into Plutus Core using a GHC plug-in called Plutus Tx.

Plutus and native tokens

Each native token comes with its own minting policy, which determines the conditions under which tokens can be minted and burnt. Users can write minting policies in Haskell and compile them to Plutus Core. During the minting or burning process, the Plutus Core policy script is executed in the context of the minting or burning transaction, and the script will have to approve or forbid the action. This feature further accelerates the growth of non-fungible tokens (NFTs) on Cardano by enabling the creation of much more complex minting policies and allowing the creation of NFTs in a trustless manner.

Advantages of Plutus

Plutus provides considerable security advantages. It delivers an easier, more robust way to show that your smart contracts are correct and will not encounter the problems found in previous smart contract language design.

Plutus enables a novel integrated approach to smart contract and distributed application development that is more convenient and safer than previous alternatives. Both the on-chain and off-chain code are based on the same language. You use a uniform code base, which the Plutus toolchain then automatically separates into on-chain and off-chain code and packages for deployment.

Additionally, in contrast to Ethereum, Plutus supports user-defined tokens (both fungible and non-fungible) natively which does not require an accompanying smart contract.

Plutus developer resources

Plutus Core

Plutus Core is the scripting language embedded in the Cardano ledger. It forms the basis of the Plutus Platform – an application development platform for developing decentralized applications (DApps) on the Cardano blockchain.

Developer resources:

  • Plutus Core GitHub repository: includes the implementation, specification, and mechanized metatheory of Plutus Core as well as Plutus Tx – the compiler from Haskell to Plutus Core.

Associated links:

Official Haskell language server implementation

Haskell language server implementation is an implementation of a server for the Language Server Protocol (LSP). A language server talks to a client, who can ask the server to perform various operations, such as reporting errors or providing code completions.

Developer resources:

Haskell course

Plutus Core is written in Haskell. To use Plutus, it is essential to know the basics of Haskell. To help with the onboarding journey, IOG's education team created the Haskell course for beginners. You can find the repository with explainers, links to lectures, and more below.

Plutus user documentation

This section includes references to Plutus user documentation such as explanations, tutorials, how-to guides, etc.

Documentation:

Plutus Pioneer Program

Plutus Pioneer community notes:

Plutus community resources

This section provides links to Plutus community resources.

If you are a community member engaged with Plutus development, please raise a pull request to add more relevant links and information.

Discussions & support:

Plutus tooling

There are different tools that developers can use to evaluate and deploy smart contracts on Cardano: