Programming on Cardano
This page will cover programming on Cardano and provide resources on how companies can start to create blockchain and Web3 functionality on top of Cardano.
EUTXO
Cardano uses an Extended UTXO model of accounting. See: https://ci.zw3rk.com/build/959629/download/1/eutxo.pdf.
EUTXO stands for Extended Unspent Transaction Output and is the accounting model used in the Cardano blockchain. This model defines how transactions are processed and how the state of the blockchain is updated.
In the EUTXO model, transactions are composed of inputs, outputs, and scripts. Inputs refer to the unspent transaction outputs (UTXOs) from previous transactions, which are used as inputs for the new transaction. Outputs represent the new UTXOs that are created as a result of the transaction. Finally, scripts are code snippets that specify the conditions that must be met for the transaction to be valid.
The EUTXO model is based on the idea that the state of the blockchain is defined by the set of all unspent transaction outputs. Each transaction updates the state by consuming some UTXOs and creating new ones. The scripts associated with each UTXO define the conditions under which it can be spent, ensuring that transactions are executed correctly and securely.
In contrast, the accounting model used in Ethereum is based on a global state. In this model, the state of the blockchain is defined by a set of account balances and smart contract storage. Each transaction updates the state by modifying account balances and smart contract storage.
The main difference between the EUTXO and Ethereum models is that the EUTXO model is more granular and focuses on individual transaction outputs, while the Ethereum model focuses on account balances and smart contract storage. This makes the EUTXO model more flexible and better suited for complex transactions involving multiple inputs and outputs.
Plutus
See:
Plutus is a programming language designed for creating smart contracts on the Cardano blockchain. In this guide, we'll explore the steps you need to follow to create a smart contract using Plutus.
If you would like to learn using hands-on project-based learning, Gimbalabs hosts regular Plutus PBL courses. More details can be found here: https://gimbalabs.com/pbl/plutus
If you would like a high-level overview of how to develop on Cardano, here is a summary of the steps that would be taken to develop smart contracts using Plutus:
Step 1: Set up the development environment
Before you start creating smart contracts with Plutus, you need to set up your development environment. You'll need a few tools to get started, including:
The Haskell programming language and related tools
The Cabal build system
The Plutus library and related tools
Detailed instructions for setting up your development environment can be found on the Plutus GitHub page: https://github.com/input-output-hk/plutus
Step 2: Create the smart contract
Once you have your development environment set up, you can start creating your smart contract. To do this, you'll need to:
Define the on-chain code - The on-chain code defines the rules and logic of the smart contract. You'll need to write this code in Haskell using the Plutus libraries.
Define the off-chain code - The off-chain code handles interactions with the smart contract from outside the blockchain. This includes things like sending transactions to the contract or retrieving data from it. You'll also write this code in Haskell.
Combine the on-chain and off-chain code - Once you've defined both the on-chain and off-chain code, you'll need to combine them into a single program that can be deployed to the blockchain.
Step 3: Test the smart contract
After you've created the smart contract, you'll need to test it to make sure it works correctly. You can do this by:
Running the code locally - You can test the smart contract on your local machine using the Plutus simulator. This allows you to test the contract's behavior without actually deploying it to the blockchain.
Deploying the code to a testnet - You can deploy the smart contract to a testnet to test its behavior in a more realistic environment. The Plutus playground provides a simulated testnet that you can use to test your contract.
Step 4: Deploy the smart contract
Once you've tested your smart contract and verified that it works correctly, you can deploy it to the Cardano blockchain. To do this, you'll need to:
Compile the code - You'll need to compile your smart contract code using the Plutus compiler. This will generate the code that can be deployed to the blockchain.
Deploy the code - Once you've compiled the code, you can deploy it to the blockchain using a Cardano transaction.
Step 5: Interact with the smart contract
Once the smart contract is deployed, you can interact with it using the Cardano blockchain. You can:
Send transactions to the contract - You can send transactions to the contract to trigger its behavior. This might include sending funds or changing the contract's state.
Retrieve data from the contract - You can retrieve data from the contract to see its current state or to view transaction history.
Aiken
Aiken is a programming language developed specifically for writing smart contracts on the Cardano blockchain. It is a high-level language that allows developers to express complex contract logic in a concise and readable manner.
Aiken is designed to be easy to learn and use, with a syntax that is similar to other mainstream programming languages. It includes features such as static typing, pattern matching, and support for algebraic data types.
One of the unique features of Aiken is its support for automatic theorem proving. This allows developers to formally verify the correctness of their contract code, ensuring that it behaves as intended and eliminating the risk of bugs or vulnerabilities.
Aiken is built on top of the Plutus framework, which provides a set of libraries and tools for writing smart contracts on the Cardano blockchain. This includes a simulator for testing contract behavior, a compiler for generating code that can be deployed to the blockchain, and a range of other utilities for working with the Cardano ecosystem.
Overall, Aiken is a powerful and flexible programming language that is well-suited to the needs of smart contract developers on the Cardano blockchain. Its combination of high-level abstractions, formal verification, and integration with the Plutus framework make it a valuable tool for creating secure and reliable contracts.
Mesh.js
See: https://meshjs.dev/
Mesh is an open-source library to advance Web3 development on Cardano. Mesh is an open-source library providing numerous tools to easily build powerful dApps on the Cardano blockchain.
Mesh is developed closely to network updates. By using Mesh, your application will always be ready for the latest network changes, so you can focus on building your application.
Getting started with dApp development has never been this easy. Mesh is conceived in a way that facilitates and speeds up development of decentralised applications.
Mesh follows many CIPs that make it interoprable with other Cardano tools. In addition, the package is less than 300kB! This means your application is fast, responsive and adheres to standards.
Why Mesh?
The word "Mesh" is defined as:
when different things or people mesh, they suit each other or work well together
(of two or more things) to fit together or be suitable for each other
Like a well-woven fabric, Mesh connects business goals with technology stacks. It enables developers to build applications according to project requirements on the blockchain. Mesh is filling the gap by making product development accessible on Cardano.
Whether you're a new developer, startup, Web3 market leader, or a large enterprise, Mesh makes Web3 development easy with reliable, scalable, and well-engineered APIs & developer tools.
Last updated