Browse by type

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>
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:
match, flow-sensitive narrowing, and the full script-context prelude
(ScriptContext, Tx, Value, Interval, …);tx.signedBy, tx.findInput, tx.valuePaidTo, Value arithmetic,
interval helpers, lists and linear maps;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;pebble repl evaluates expressions, declarations and tests
against your project's files, and shows each value with its cpu/mem cost;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;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;two_party_escrow real-world benchmark and the factorial open
benchmark (where it leads memory too) — see
BENCHMARKS.md and the
live report.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.
command line (the pebble command)
npm install -g @harmoniclabs/pebble-cli
or as library (in your project root dir)
npm install @harmoniclabs/pebble
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.
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.if, for, while, trace, assert, fail, x = ....
What they change in a let is kept.test name() { ... } runs at once.pebble test.lets.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.
Have a look at the pebble documentation where you can find some example projects to help you get started.
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.
a collection of all proposals made in the past is in the catalyst-proposals.md file
browse all types & interfaces →
$ claude mcp add pebble \
-- python -m otcore.mcp_server <graph>