A guide to building safe, expressive smart contracts on Bitcoin.
Bithoven is a high-level, imperative programming language designed for Bitcoin smart contracts. It bridges the gap between complex contract logic and the low-level stack machine of the Bitcoin Virtual Machine (VM).
Unlike writing raw Bitcoin Script—which is notoriously difficult and
error-prone—Bithoven allows you to write readable, auditable code with
modern control flow (if/else), named variables, and built-in safety checks. It compiles down to
highly optimized native Bitcoin Script.
Why Bithoven?
You can install the Bithoven compiler via the command line or package managers.
Try Bithoven instantly in your browser without installation:
Go to Bithoven Online IDE
A Bithoven contract (file extension
.bithoven) consists of three main parts:
Pragmas define the compiler version and the Bitcoin protocol target.
The
target
controls opcode generation.
legacy: Generates P2SH-compatible
script.
segwit: Generates P2WSH-compatible
script.
taproot: Generates P2TR-compatible
script (uses
OP_CHECKSIGADD).
| Type | Description | Example |
|---|---|---|
| bool | Boolean values | true |
| number | Integer values (32-bit signed) | 1000 |
| string | Hex or ASCII string data | "secret" |
| signature | ECDSA or Schnorr signatures | sig_alice |
| pubkey | Valid public key point | "0245..." |
Bithoven allows you to define multiple valid "spending paths" at the top of your file. The compiler verifies that every path is secure.
Use standard if/else logic.
Halts execution if false.
Keywords enforce 32-bit limits automatically.
n blocks.
n.
Hashing:
sha256(data),
ripemd160(data)
Signature Checks: Supports single and multisig via
checksig.
Bithoven is "Correct-by-Construction." The static analyzer runs during compilation.
Ensures every variable (especially signatures) is consumed exactly once. Prevents signature reuse and resource exhaustion.
Analyzes execution paths to ensure safe termination. Prevents Anyone-Can-Spend bugs.
Strictly validates types. Prevents consensus failures like arithmetic on strings or invalid public key points.
A standard contract used in Lightning Network. Alice can refund after a delay; Bob can redeem immediately with a secret.
Owner spends anytime. Heir spends after 1000 blocks with secret. Lawyer+Auditor multisig after 10,000 blocks.