Plutus
To start developing with Plutus, see:
- Plutus Core documentation
- Developer portal Plutus overview
- 'Plutus resources' below for more details.
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 Core and Plutus Tx user guide: introduces the Plutus Core programming language and programming with Plutus Tx. Documentation includes explanations, tutorials, how-to instructions, troubleshooting, and reference information:
-
Video presentation on the Plutus Platform: in this session from the 2020 Cardano Summit, Michael Peyton-Jones walks us through working with Plutus, while Jann Müller then takes us through the Plutus Application Platform, where assets can be built and launched. He also demonstrates how tokens can be transferred using a smart contract.
Plutus Pioneer Program
- Plutus Pioneer Program: includes lectures, examples, and exercises
- Plutus Pioneer Program notes and documentation
- 'plutus-pioneer-program' questions on Cardano Stack Exchange
- Plutus Pioneer Discord
Plutus Pioneer community notes:
- How to prepare for the Plutus Pioneer Program
- Essential Resources and Documentation for the Plutus Pioneer Program
- Plutus Pioneer Program Part 1: Understanding the eUTXO Model and Coding the first Smart Contract
- Plutus Pioneer Program - Part 2: How to “deploy” a Smart Contract in Cardano
- Plutus Pioneer Program - Part 3: How to Mint and Burn Tokens and NFTs in Cardano
- Plutus Pioneer Program - Part 4: State Machine with Plutus (1/2)
- Plutus Pioneer Program - Part 5: State Machine with Plutus (2/2)
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:
-
An extended list of community-built developer tools on Cardano: includes NFT creation tools, smart contract platforms, software libraries, APIs, interfaces, SDKs, digital product platforms, data services, blockchain integration, automation tools, decentralized protocols, enterprise apps, stake pool tooling, and more.
-
Emurgo
-
Plutonomicon
-
OpShin
-
Harmonic
-
TxPipe
- Aiken
- Oura
- Scrolls
- Pallas
- Demeter Run - a cloud environment with all the tools for building DApps on Cardano
-
dcSpark
-
MLabs
-
dQuadrant
-
CardanoSolutions
-
Other tools