Skip to content

The bboard example is a Compact contract, a CLI environment and a UI built with React to deploy and interact with the contract that can be used as a template to start building on Midnight

License

Notifications You must be signed in to change notification settings

midnightntwrk/example-bboard

Bulletin Board DApp

Generic badge Generic badge

A Midnight smart contract example demonstrating a simple one-item bulletin board with zero-knowledge proofs on testnet. Users can post a single message at a time, and only the message author can remove it.

Project Structure

bulletin-board/
├── contract/               # Smart contract in Compact language
│   └── src/               # Contract source and utilities
├── api/                   # Methods, classes and types for CLI and UI
├── bboard-cli/            # Command-line interface
│   └── src/               # CLI implementation
└── bboard-ui/             # Web browser interface
    └── src/               # Web UI implementation

Prerequisites

1. Node.js Version Check

You need Node.js (tested with current LTS):

node --version

Expected output: v22.15.0 or higher.

If you get a lower version: Install Node.js LTS.

2. Docker Installation

The proof server runs in Docker and is required for both CLI and UI to generate zero-knowledge proofs:

docker --version

Expected output: Docker version X.X.X.

If Docker is not found: Install Docker Desktop. Make sure Docker Desktop is running.

3. Lace Wallet Extension (UI Only)

For the web interface, install the Lace wallet browser extension from your browser's extension store.

Setup Instructions

Install Project Dependencies

# Install root dependencies
npm install

# Install API dependencies
cd api && npm install && cd ..

# Install contract dependencies and compile
cd contract && npm install

Compile the Smart Contract

The Compact compiler generates TypeScript bindings and zero-knowledge circuits from the smart contract source code:

cd contract
npm run compact    # Compiles the Compact contract
npm run build      # Copies compiled files to dist/
cd ..

Expected output:

> compact
> compact compile src/bboard.compact ./src/managed/bboard

Compiling 2 circuits:
  circuit "post" (k=14, rows=10070)
  circuit "takeDown" (k=14, rows=10087)

> build
> rm -rf dist && tsc --project tsconfig.build.json && cp -Rf ./src/managed ./dist/managed && cp ./src/bboard.compact ./dist

Build the CLI Interface

cd bboard-cli
npm install
npm run build
cd ..

Build the UI Interface (Optional)

Only needed if you want to use the web interface:

cd bboard-ui
npm install
npm run build
cd ..

Option 1: CLI Interface

Start the Proof Server

The proof server must be running before using the CLI to generate zero-knowledge proofs for transactions:

cd bboard-cli
docker compose -f proof-server-testnet.yml up -d

Verify it's running:

docker ps

Run the CLI

npm run testnet-remote

Using the CLI

Create a Wallet

  1. Choose option 1 to build a fresh wallet
  2. The system will generate a wallet address and seed
  3. Save both the address and seed - you'll need them later

Expected output:

Your wallet seed is: [64-character hex string]
Your wallet address is: mn_shield-addr_test1...

Fund Your Wallet

Before deploying contracts, you need testnet tokens.

  1. Copy your wallet address from the output above
  2. Visit the testnet faucet
  3. Paste your address and request funds
  4. Wait for the CLI to detect the funds (takes 2-3 minutes)

Expected output:

Your wallet balance is: 1000000000

Deploy Your Contract

  1. Choose the contract deployment option
  2. Wait for deployment (takes ~30 seconds)
  3. Save the contract address for future use

Expected output:

Deployed bulletin board contract at address: [contract address]

Use the Bulletin Board

You can now:

  • Post a message to the bulletin board
  • View the current message
  • Remove your message (only if you posted it)
  • Exit when done

Each action creates a real transaction on Midnight Testnet using zero-knowledge proofs generated by the proof server.

Option 2: Web UI Interface

The web interface uses the same proof server and requires additional browser setup.

Start the Proof Server (if not already running)

If you haven't started the proof server for the CLI, start it now:

cd bboard-cli
docker compose -f proof-server-testnet.yml up -d

Verify it's running:

docker ps

Start the Web Interface

cd bboard-ui
npm run start

The UI will be available at:

Browser Setup

  1. Open the UI URL in a browser with Lace wallet extension installed
  2. Set up Lace wallet if it's your first time
  3. Authorize the application when Lace wallet prompts
  4. Use the bulletin board web interface

Useful Links

Troubleshooting

Common Issue Solution
npm install fails Ensure you're using Node.js LTS version. If you get ERESOLVE errors, try npm install --legacy-peer-deps
Contract compilation fails Ensure you're in contract directory and run npm run compact
Network connection timeout CLI requires internet connection, restart if connection times out
Token funding takes too long Wait 1-2 minutes, funding is automatic in CLI
"Application not authorized" error Start proof server: docker compose -f proof-server-testnet.yml up -d
Lace wallet not detected Install Lace wallet browser extension and refresh page
Docker issues Ensure Docker Desktop is running, check docker --version
Port 6300 in use Run docker compose down then restart services
Dependencies won't install Use Node.js LTS version. For older npm versions, you may need --legacy-peer-deps
Contract deployment fails Verify wallet has sufficient balance and network connection

Notes

  • CLI and UI can run simultaneously and share the same proof server
  • Proof server (Docker) is required for both CLI and UI to generate zero-knowledge proofs
  • Contract must be compiled before building CLI or UI
  • Fund your wallet using the testnet faucet before deploying contracts

About

The bboard example is a Compact contract, a CLI environment and a UI built with React to deploy and interact with the contract that can be used as a template to start building on Midnight

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors 9