MCPcopy Create free account
hub / github.com/HarmonicLabs/pebble

github.com/HarmonicLabs/pebble @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
3,140 symbols 7,286 edges 565 files ⚖ Apache-2.0 158 documented · 5% ● updated 8d agov0.5.0 · 2026-10-26★ 1784 open issues

Browse by type

⨍ Functions 2,440◇ Types & classes 700
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

A simple, yet rock solid, functional language with an imperative bias, targeting UPLC

<img src="https://img.shields.io/github/commit-activity/m/HarmonicLabs/plu-ts?style=for-the-badge" />
<a href="https://twitter.com/hlabs_tech">
  <img src="https://img.shields.io/twitter/follow/hlabs_tech?style=for-the-badge&logo=twitter" />
</a>
<a href="https://twitter.com/MicheleHarmonic">
  <img src="https://img.shields.io/twitter/follow/MicheleHarmonic?style=for-the-badge&logo=twitter" />
</a>

what is pebble?

Pebble is a smart-contract language for Cardano with TypeScript-shaped syntax — const, if, C-style for loops, structs, generics, modules — compiled to Untyped Plutus Core (UPLC) by a whole-program optimizing compiler. You write imperative-looking code; the compiler lowers loops to tail recursion, places every computation exactly once, and emits compact scripts that use the newest on-chain features (UPLC 1.2 case/constr, the protocol-version-11 builtins).

What you get out of the box:

  • a type system built for validators: data-encoded and sum-of-products structs, generics with monomorphization, exhaustive match, flow-sensitive narrowing, and the full script-context prelude (ScriptContext, Tx, Value, Interval, …);
  • a standard library covering the common dApp patterns — tx.signedBy, tx.findInput, tx.valuePaidTo, Value arithmetic, interval helpers, lists and linear maps;
  • a built-in test framework: pebble test runs unit and property tests on the real CEK machine, with typed fuzzers for every parameter type, user-defined via fuzzers, failing-input shrinking, and per-test cpu/mem budgets;
  • a REPL: pebble repl evaluates expressions, declarations and tests against your project's files, and shows each value with its cpu/mem cost;
  • source maps and a debugger: a failing script says which line of the Pebble source failed (in pebble test and in buildooor), and pebble debug shows a test or a failed transaction statement by statement with the variables' values (--json for tools and AI agents); the VS Code extension steps through it forwards and backwards;
  • traces that cost nothing on chain: removeTraces compiles the script as if its traces were not there, and the source map keeps them, so tests, the debugger and buildooor still print them;
  • competitive output: Pebble holds the lowest CPU numbers in the UPLC-CAPE two_party_escrow real-world benchmark and the factorial open benchmark (where it leads memory too) — see BENCHMARKS.md and the live report.

Benchmarks

Pebble is benchmarked against Aiken, Plinth, Plutarch, Scalus and OpShin in IntersectMBO's UPLC-CAPE suite: results and methodology in BENCHMARKS.md, rendered charts on the live report.

Install

command line (the pebble command)

npm install -g @harmoniclabs/pebble-cli

or as library (in your project root dir)

npm install @harmoniclabs/pebble

Try it in the REPL

The REPL runs Pebble line by line, with the files of the project you start it in:

npm install -g @harmoniclabs/pebble-cli
git clone https://github.com/HarmonicLabs/pebble.git
cd pebble/examples/uplc-cape
pebble repl
Pebble REPL 0.6.0, project .../pebble/examples/uplc-cape
Type :help for help.
pebble> import { factorial } from "./src/factorial.pebble";
pebble> factorial(5)
120
cpu: 2766005 | mem: 11221
pebble> import { fibonacci } from "./src/fibonacci.pebble";
pebble> fibonacci(10)
55
cpu: 6289504 | mem: 25047
pebble> const n = factorial(4);
pebble> fibonacci(n)
46368
cpu: 16831474 | mem: 64745
pebble> :quit

Each line runs as one program, made of the declarations entered so far and the line, on the same machine as pebble test. The cost shown is that program's, so fibonacci(n) includes computing n.

  • Expressions show their value, in Pebble syntax (P{ x: 1, y: 2 }, [1, 2, 3], #abcd).
  • const, let, function, struct, import and contract are kept for the lines after. Redeclaring a name replaces it.
  • Statements run: if, for, while, trace, assert, fail, x = .... What they change in a let is kept.
  • test name() { ... } runs at once.
  • Contracts are type-checked. Their methods need a script context, so they run under pebble test.
  • Functions, contracts and tests can use constants and other declarations, not lets.
  • A line that fails changes nothing. Errors point at what you typed.
  • A line can spend what a mainnet transaction can: 10,000,000,000 cpu and 16,500,000 mem. An endless loop stops there.

Commands: :help, :list (the declarations kept), :reset, :quit (also Ctrl+D, or Ctrl+C twice). Lines can be piped in (pebble repl < session.txt): the output reads as a session, and the exit code is 1 if a line failed. The REPL reads the nearest pebble.config.json (or --config), and writes nothing.

Get started

Have a look at the pebble documentation where you can find some example projects to help you get started.

Sponsors ❤️

the sponsors.md file contains a list of supporters of this project.

Every one of them is special and is contributing to making this software available for everyone.

Project Catalyst

a collection of all proposals made in the past is in the catalyst-proposals.md file

Extension points exported contracts — how you extend this code

browse all types & interfaces →

Core symbols most depended-on inside this repo

browse all functions →

Shape

Method 1,717
Function 723
Class 571
Interface 110
Enum 19

Languages

TypeScript100%

Modules by API surface

packages/pebble/src/compiler/tir/expressions/binary/TirBinaryExpr.ts180 symbols
packages/pebble/src/IR/IRNodes/IRNative/index.ts157 symbols
packages/pebble/src/compiler/tir/expressions/TirNativeFunc.ts117 symbols
packages/pebble/src/parser/Parser.ts69 symbols
packages/pebble/src/ast/nodes/expr/binary/BinaryExpr.ts63 symbols
packages/pebble/src/compiler/tir/types/TirNativeType/TirNativeType.ts57 symbols
packages/pebble/src/ast/nodes/statements/AssignmentStmt.ts48 symbols
packages/pebble/src/compiler/tir/types/TirStructType.ts43 symbols
packages/pebble/src/tokenizer/Tokenizer.ts40 symbols
packages/pebble/src/compiler/AstCompiler/AstCompiler.ts40 symbols
packages/pebble/src/compiler/AstCompiler/scope/AstScope.ts34 symbols
packages/pebble/src/ast/nodes/types/AstNativeTypeExpr.ts33 symbols

For agents

$ claude mcp add pebble \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page