Tutorial: building a bulletin board smart contract with Compact

Avatar of the content author
Sign up now so you never miss an update
contributors
Avatar of the content author
Claude BardeDeveloper Relations Engineer
Avatar of the content author
Thiago EarpContent Marketing Lead
This tutorial takes you through the process of creating a simple bulletin board written in Compact, Midnight’s smart contract language.

Just getting started building on Midnight and can’t wait to see your first smart contract in action? Watch the video below to learn how to write a simple bulletin board contract. For all the prerequisites, full code, and instructions, check out the Midnight docs.

Bulletin board smart contract overview

The contract you’ll build in this tutorial is a simple bulletin board system that allows users to post a message and take them down. The contract makes use of zero-knowledge proofs to protect the poster's identity. It ensures that only the original poster can take down their message and that no other message can be posted while a message is up.

This contract demonstrates the basic principles of writing a contract in Compact and provides a starting point for more complex applications. Remember to always test and verify your contracts before deploying them to the blockchain.

Building a bulletin board smart contract with Compact

About Compact

Compact is a high-level, typed programming language designed for writing smart contracts on the Midnight network. Compact is designed to be easy to learn and use, with a syntax similar to TypeScript. It provides a range of features that make it well-suited for writing smart contracts, including:

  • Statically typed: Compact is a statically typed language, which means that the type of every expression is known at compile time. This prevents type-related errors at runtime and makes it easier to write and maintain large contracts.
  • Functional programming: Compact supports functional programming concepts, such as pure functions and immutable data structures. This makes it easier to write composable, modular code that is easy to reason about.
  • Witnesses: JavaScript functions that have access to the private state, but whose results are not seen on chain unless you explicitly decide to reveal them.

Keep learning

To continue your journey and get deeper into all things Compact and Midnight, head to the docs and start building.


Share