Skip to content
arkade-osPublic

About

A high-level language that compiles to Arkade Script for building Bitcoin-native smart contracts with Arkade

Resources

Security policy

Stars

17 stars

Watchers

1 watching

Forks

Repository files navigation

Arkade: a contract language for Bitcoin

Arkade Compiler

Build Release GitHub release crates.io License: MIT

Arkade Language is a contract language for Bitcoin. You write a contract as a set of spend functions over constructor state.

The compiler, arkadec, turns a contract into a JSON artifact. Arkade libraries consume the artifact directly.

The language covers signature and multisig checks, absolute and relative timelocks, transaction introspection, Arkade Assets and asset groups, byte-string parsing, fixed-size arrays, structs, and instantiation of other contracts with new.

Spending paths

Each spending path is enforced in one of two ways:

  • Operator-enforced: the operator runs the path's Arkade Script before it cosigns.
  • Bitcoin-enforced: the path uses only Bitcoin Script, so Bitcoin can enforce it alone, as with every party's unilateral exit.

The two kinds of function map onto them, and the artifact carries both kinds of script:

Function Compiles to Defines
Arkade Script function: a function without a modifier Arkade Script An operator-enforced path
Tapscript function: a function marked tapscript An L1 tapscript leaf A Bitcoin-enforced path, unless it is bound to an Arkade Script function
contract SingleSig(pubkey user) {
  function spend(signature userSig) {
    require(checkSig(userSig, user));
  }

  function unilateral(signature userSig) tapscript {
    require(older(operatorExitDelay));
    require(checkSig(userSig, user));
  }
}

A tour by example explains this contract and builds on it.

Quick start

Try it without installing anything in the browser playground. Files saved in the previous playground stay in that browser.

To compile locally, install arkadec and run it on a contract:

cargo install arkade-compiler --locked
arkadec contract.ark                     # writes contract.json

Command line covers prebuilt binaries and every option. From JavaScript or TypeScript, use the @arkade-os/compiler package.

Documentation

Guides

Page Covers
Tour by example Short contracts for each feature, and the examples/ directory
Playground The browser editor, its output tabs, and running it locally
Command line Installing, arkadec options, and the script report
APIs The npm package, the Rust API, and the WASM bindings
Artifact format Artifact fields, codeHash, the debug file, and the Arkade Script stack ABI
Lints Every lint, lint attributes, and CLI levels

Language reference

Page Covers
Syntax, literals and constants File layout, lexical rules, the version pragma, byte literals, constants
Imports and libraries Import scope and loading, libraries
Types Scalar and native types, structs, arrays, casts
Functions and statements Spend groups, helpers, statements, initialization
Expressions Operators, precedence, and when evaluation fails
Built-ins Signatures, hashes, time, introspection, assets, bytes, curves
Tapscript functions Leaf shape, keys, and binding leaves to Arkade Script functions

Contributing

Development covers tests, end-to-end and fuzz testing, and releasing.

Security

See SECURITY.md for the disclosure process.

About

A high-level language that compiles to Arkade Script for building Bitcoin-native smart contracts with Arkade

Resources

Security policy

Stars

17 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages