File Structure

The structure of a btm file is the following:

  • package declaration (optional)
  • network declaration (optional)
  • constants and transactions declaration
  • compile statement (optional)


The package declaration specify where the generated files must be saved. By default, generated files are saved in src-gen with a directory structure reflecting the package name. For example, declaring package com.example.test, the generated files will be store in src-gen/com/example/test/.

package com.example.test

The package declaration is optional, but recommended, and must appear at the beginning of the file. The name of the package follows the same rules and conventions of Java packages.


Several static checks depend on the network you are considering. The Wallet Import Format [1], used to represent private keys and addresses, include a network identifier which made it wrong outside that network. Furthermore, since we are generating transactions, the network declaration is needed for serialization.

The network declaration is optional. If omitted, the testnet network is considered by default. If specified, the network declaration must appear right after the package declaration.

package com.example.test

// <-- you can put comments here

network testnet
package com.example.test

/* <-- you can put multi-line comments here */

network mainnet


Constants are immutable global variables. The syntax is const __name__ [: __type__] = __expression__. For example:

const n = 42
const n:int = 42

The type can be omitted, because it is inferred by the expression. Refer to Types and Expressions for details.


See Transactions.


Constant and transaction declarations can be mixed together.

It is allowed to write:

const n = 42

transaction T { /* ... */ }

const s = "Hello world"


Cross-references are resolved independently from the declaration order, so it is allowed to write:

const n = 21 * m
const m = 2


The compile statement takes a list of expression and compile them. The compiled expressions are saved in text format in src-gen/_package-path_/transactions.

transaction T { /* ... */ }
transaction T1(a:int) { /* ... */ }
const n = 11

        32          // compiles 32
        T           // compiles T as a bitcoin transaction
        T1(42)      // compiles T1(42) as a bitcoin transaction
        (n + 5)     // compiles 16