Skip to content


The etch language integrates with the Ledger project. It is designed to run on a number of platforms.

etch is inspired by Rust, C++, and Python, but it also has some idiosyncrasies.

The etch language is extremely restrictive to avoid costly errors on the ledger. See Smart Contract section for more information.

etch is a statically typed language and static typing is enforced by the compiler.


Blocks of code require no delimiters. White space is ignored. Indentation is recommended.

You can extend and customise etch in C++. We show you how to do that here.

Let's take a closer look at etch.


Explicitly declare the type:

function main()

    var myvariable : String;


In some cases, type can be inferred:

function main()

    var myvariable = "hello";


Assign a value like this:

function main()

    var myvariable : String = "hello";


For multivariate types, all the types must be declared:

var multitype-variable-name : Type<Type<Type>>();

Not declaring the variable type and inferrable value results in a compilation error:

function main()

    var myVariable;


Failed to compile.
line 3: error at ';', expected ':' or '='
Failed to compile.

[!comment]: (All variables in etch receive a default value at compile time.)


Initially, all our code snippets execute inside the main function:

function main()

    // stuff



Here is a current list of etch keywords:

var if endif else for
endfor while endwhile function endfunction
break continue return persistent sharded
use as any @init @action
@problem @objective @work @clear


Both line and block comments are possible:

// a single comment inside a function

   ..lines of commented out stuff inside and outside functions


etch code for smart contracts includes annotated functions. These are more like Java method annotations and not at all like Python decorators:

  • @init is a constructor method that initialises the contract.

  • @action is a function which defines transactions on the ledger that change state.

  • @query is a function that allows you to query data residing on the ledger.

There are further annotations for synergetic contracts. Find out about these functions and more in the section on smart contracts.