Safer, Smarter Contracts with Pact

How Kadena’s smart contract language supports blockchain adoption

Vivienne Chen
Feb 20 · 6 min read

The State of Smart Contracts

The term ‘smart contracts’ was first introduced by Nick Szabo in the late 1990’s where he defined them as:

“a computerized transaction protocol that executes the terms of a contract. The general objectives are to satisfy common contractual conditions (such as payment terms, liens, confidentiality, and even enforcement), minimize exceptions both malicious and accidental, and minimize the need for trusted intermediaries.”

- Nick Szabo, “Smart Contracts”

Bitcoin, as the first decentralized cryptocurrency, offers scripts written in a minimal, non-Turing complete bytecode language. These scripts cannot function as complete smart contracts — their primary usage is allowing a custody check to succeed or fail on a given Bitcoin amount (an “output”). Programmers are able to timestamp other transactions using extra data fields in the transaction with infinitesimal amounts of Bitcoin, but these were considered “hacks” and indeed, custom scripts are prohibited by production Bitcoin systems. These limitations motivated the eventual creation of Ethereum.

  1. If smart contracts face great risk and vulnerabilities, then blockchain adoption will stall as businesses will hesitate to adopt, test, and experiment with new, unproven, and risky technologies.
  2. Human error is an inevitable point of vulnerability in all smart contracts and needs to be accounted for in any programming language designed to serve humans.

Smart Contracts in Pact

Pact is an open-source Turing-incomplete smart contract language that has been purpose-built with blockchains first in mind. Pact focuses on facilitating transactional logic with the optimal mix of functionality in authorization, data management, and workflow.

A snapshot of a payments contract from pact.kadena.io

Interpreted Code

Pact code is executed directly on the ledger and is stored in a human-readable format as an immutable transaction. This means Pact smart contracts can be openly verified by anyone.

Turing Incomplete

We consider Pact a spiritual successor to Bitcoin scripts — Bitcoin scripts served as inspiration for Pact and they share several similarities, one of which is that they are both Turing incomplete, meaning they do not allow recursion or infinite loops. In Pact, any recursion that is detected will cause an immediate failure and terminate all running code. This feature significantly reduces any potential attack vectors that may be present in smart contracts.

Blockchain Governance

Unlike Solidity-based contracts, Pact smart contracts can be updated, changed, or fixed through an update mechanism to declare new versions of a smart contract that are applied only once the new code has been successfully executed. Any errors will automatically roll back the smart contracts to their previous state and abort making any new changes. This feature allows developers to fix potential errors and for contracts with multiple parties to update their agreements to represent evolutions in business logic.

Pact APIs

Similarly to how understanding smart contract code should not be confined to only developers, we also believe smart contract data should not be stored only on-chain. This tenet is why Pact has API functionality so that data stored in smart contracts can be extracted into external databases via SQL.

Formal Verification

Pact also comes equipped with a powerful validation tool suite in the form of formal verification. Pact uses Z3, an open source tool developed by Microsoft, to mathematically verify and test for bugs present in code.

The Future of Smart Contracts

For blockchain to truly realize its transformative potential, we need to commit to providing developers and users with smart contracts that they know they can trust. Pact has been designed from the ground up to offer developers a simple way to implement secure and bug-free smart contracts. Pact ships with a feature-rich REPL which allows for rapid, iterative development, incremental transaction execution, and environment and database inspection. Developing with Pact code is meant to be fun and productive; please visit our Github and Read The Docs page to learn more and try Pact out immediately using your browser.

We’re also on: Twitter | Linkedin | Facebook| Github| Reddit| Discord | Telegram

Kadena

the new frontier of smart contracts on blockchain

Vivienne Chen

Written by

Communications & Media Manager at Kadena.io

Kadena

Kadena

the new frontier of smart contracts on blockchain