Pact 5: The Next-Generation Smart Contract

Pact 5: The Next-Generation Smart Contract
Emily Pillmore

Emily Pillmore

January 17, 2024

Pact 5: The Next-Generation Smart Contract

How Pact 5 Will Shape the Future of Blockchain Technology

Smart contract technology is becoming increasingly sophisticated as the crypto industry matures. Realizing the full potential of blockchain technology is not necessarily in the complexity and intricacies of the consensus mechanisms that drive our blockchains but in the myriad of ways we can harness that technology and express more complicated behaviors in terms of them.

Smart contracts and smart contract languages, as it were, are the key to unlocking these capabilities. Smart contracts can model our currencies, commodities, more exotic financial instruments, and even our digital identities in one form or another. They can model our digital lives.

This is why Kadena places so much emphasis on our smart contract language: Pact.

Reintroducing Pact

For this industry to truly build useful and valuable systems, smart contracts must be trustworthy. They must be built of individually trustworthy components assembled safely and predictably to gain that trust. In addition, a smart contract language needs to adopt the notion that there are many such blockchains with many incredible features, providing a means of interfacing with them in a robust and, hopefully, decentralized manner. Pact 5 is a step in that direction.

Better Performance

At its heart, Pact 5 enhances performance using trusted techniques well-known to the programming language community. This rewrite has nothing fancy: only tried and tested engineering techniques done well. The Pact Team is focusing on several key features here:

  • Speed: Faster execution of smart contracts, leading to more transactions and a more responsive experience.
  • Stability: A stronger foundation for our blockchain, reducing errors and improving overall network health.
  • Efficiency: Smoother updates and enhancements leading to a more agile and adaptable platform.

The effect is that programs executed on Kadena’s Chainweb blockchain and any blockchain that supports the Pact interpreter will see more deterministic transactions with higher throughput.

A Better Developer Experience

The ubiquity of tooling in the modern developer experience has not gone unnoticed at Kadena. Language ecosystems such as Go, Rust, Java, and Haskell have deeply integrated tooling ecosystems considered jewels of the programming industry. Some would argue that the tooling ecosystem — the ease by which we develop, test, analyze, and deliver programs — is more important than the language itself. The success of these languages cannot be overstated. However, the significance of related tooling often is.

With this in mind, the Pact team is offering the following for Pact 5:

  • A new and improved Language Server Protocol (LSP): we’ve added new features that offer more robust feedback for the developer, including tooltip documentation (hover-on-point), step-to-definition, and many others. We also offer an updated VSCode plugin integration for the LSP.
  • Better errors: More readable and actionable errors, along with more legible error formats
  • Debugging: A new step-debugger for the REPL. Additionally, new debugging options for a variety of compiler phases so that contract authors can hone their code and gas usage
  • A New Grammar: A new and up-to-date static grammar for tooling authors.

Kadena deeply values great developer and user experiences, and we are learning about them and working all the time to improve the state of both in all of our projects. Pact is no exception: Pact 5 was built with the notion that the compiler API and relative developer and user-facing APIs are equally important. Further, for our language to expand its reach, we must also make those APIs welcoming for third parties.

As Little Churn As Possible

The greatest of the engineering feats for the Pact 5 release is that we expect the binary to be a drop-in replacement for most users on older versions of Pact. This means that one will simply be able to download the binary, and contracts will immediately compile, up to errors fixed from previous versions of Pact. Gas usage will likely change, but all the tools are available now to diagnose this and adjust accordingly.

How Do I Get Pact 5?

Pact 5 is a massive undertaking for the Core Engineering team at Kadena, and we understand our responsibility to deliver a language that you love. We’re taking our time with this one: the release cycle is split into several phases.

  1. Alpha-release: January 2024. This release marks the initial release of Pact 5 as it reaches semantic equivalence with older Pact versions. It includes a preliminary release of some DX/UX features described above. Still, at this point, we expect the binary to enter extensive testing within the Kadena ecosystem so that we can reduce churn as much as possible by the time we release this to users. Community members can download the source code and play with the binaries. However, as with any alpha release, it is not considered “user-ready” at this point, so please be patient!
  2. Beta-release: April 2024: This release marks the point at which we consider the project “user-ready,” to the point where we welcome any users to come to kick the tires. By beta release, we should have full node integration so that users can spin up a local Chainweb node or a local server in general and send transactions to the Pact Service API. At this point, the team enters into the performance-testing epoch, when we hone the interpreter's performance and the gas model that will eventually be used in the mainnet Chainweb nodes. Users can expect preliminary documentation to be available for new features and changes to the UX/DX. We welcome any issues to be raised at this time by the community.
  3. Full-release: June 2024: This release marks full integration with Pact 5 on mainnet. Pact 5 is released to the wild!

The repository is now public for anyone who wants to watch and/or participate in the Pact 5 lifecycle. Additionally, once the beta release happens, binaries will be available via PPM for Apt users on Linux, Homebrew for Mac, or as a standalone binary artifact release on the Github repository.

Conclusion

The next generation of Pact is at our doorstep. With its release, Kadena and its ecosystem can truly realize its transformative potential, providing developers and users with smart contracts they know they can trust and a development experience they can truly enjoy.

Kadena continues to provide a world-class blockchain ecosystem with the industry's most innovative smart contract language. We hope you’ll participate in both.

*A note for historical context

A Short History of Pact 5

Historically, Pact 5 was referred to by its working name, “Pact Core,” about a need that arose from a funding idea in collaboration with Polkadot and the Web3 Foundation. This idea was that the Pact interpreter needed to fit into a smart contract to integrate with the Polkadot infrastructure.

This was a cool idea, but it required changes to the Pact internals to accomplish this. In particular, Pact needed distinct compiler phases and a minimalist interpreter to interpret an untyped “core” language — a minimalist intermediate representation similar to machine code for some virtual machine on-chain. It's kind of like EVM bytecode!

As time went on, the project evolved into something bigger. The Pact team realized that to unlock Pact’s innovative and robust feature set for third parties, the same kind of changes needed to be made. If Pact ever emits WASM code or ZK circuits, we’d need to do this anyway! Pact's language didn’t necessarily need to change; only its internals did. So, in 2022/2023, the Pact team scoped the existing Pact Core repository for delivery and began work on it in earnest in late 2023.