Native scripts are simpler, non-Turing-complete scripting solutions on Cardano. They are used primarily for multi-signature transactions and simple, pre-defined logic that does not require complex computation. Native scripts are processed directly by the Cardano ledger and have limited functionality compared to Plutus scripts.

Key Characteristics:

  • Non-Turing-Complete: Native scripts do not support loops, recursion, or complex logic, meaning they are designed for simple and predictable operations.
  • Transaction-focused: They are typically used to define conditions for multi-signature transactions, time-locked transactions, or similar straightforward requirements.
  • Ledger-based: Native scripts run directly within Cardano’s UTxO model and are processed by the ledger without requiring a virtual machine or complex computational resources.
  • Low Resource Consumption: Because they lack complex logic, native scripts consume fewer resources, making them efficient in terms of both execution time and transaction fees.

Example Use Cases:

  • Multi-Signature Transactions: Native scripts can be used to require multiple parties to sign a transaction before it is valid.
  • Timelocks: You can use native scripts to enforce time constraints on transactions (e.g., ensuring that funds are only spendable after a certain block height).
  • Basic Logic: Simple conditions such as “A or B must sign” or “funds can only be spent after a specific time” are handled by native scripts.

Example:

A simple native script could require that either two specific addresses sign a transaction or that a specific time period has passed before the transaction becomes valid.

Native Script Code Example

Native scripts are simple and are used for tasks like multi-signature or time-locking. Here’s an example of a multi-signature native script where the transaction requires either Alice or Bob to sign it for it to be valid.

Real-World Example: Multi-Signature Native Script (JSON format)

{
  "type": "any",
  "scripts": [
    {
      "type": "sig",
      "keyHash": "ed25519_pk1yqdm9czr44d0tpwyw6fg0znf0lveaxt6e0p58qxj0x3k6fdpzrlsd5vsl9" // Alice's public key hash
    },
    {
      "type": "sig",
      "keyHash": "ed25519_pk1s4hdm9azczbscy0lrk9fwpxdsndaxj9zj9f2sm6lhgj34cnksyfj0lpfwy" // Bob's public key hash
    }
  ]
}

Explanation:

  • “type”: “any”: This means that the script will be satisfied if any of the conditions listed is met.
  • “sig”: Specifies that the condition is based on a signature (multi-signature).
  • “keyHash”: The public key hash of Alice and Bob. Either one can sign the transaction for it to be valid.

This script is simple and used for multi-signature transactions. It doesn’t have complex logic like loops or recursion and is processed directly by the Cardano ledger.

Conclusion

  • Native scripts are ideal for simpler tasks like multi-signature transactions and time-locked transactions. They are efficient, but limited in terms of functionality.
  • Plutus scripts offer full programmability and are designed for more complex decentralized applications, enabling a wide range of smart contract functionalities on Cardano.

Both native and Plutus scripts serve essential roles within Cardano’s ecosystem, with native scripts providing straightforward, low-cost solutions, while Plutus scripts enable more sophisticated decentralized applications and smart contracts.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *