Contract Definitions

The basic structure of a smart contract written is fi is fairly simple, and takes a similar approach to other object-oriented languages. The core definitions include Constants, Storage Variables, Structs and Contract Entry Points.

Furthermore, we are also working on additional definitions for internal functions and response functions (for contract to contract communication via a promise-like system).


Constants can be defined and reused throughout your code like any other global constant. Constants can only be defined as basic types.

const <type*> <constant name> <literal value>;

const int ONEHOUR 3600;

Storage Variables

Storage variables are permanently stored within the block chain and represent the state of the contract. Storage variables can be of any type (basic and complex, as well as custom types defined as structs).

These variables must be defined, and can be accessed via the storage object:

storage <type|struct> <variable name>;

Which can then be accessed via the storage object:

storage.<variable name>

storage int counter; 
#Storage variable named counter, accessed via storage.counter

entry increaseCounter(){
    storage.counter.add(int 1);


Structs allow you to define more complex custom types to be used within fi. Once a struct has been declared, it can be used as a variable type.

struct <struct name>(<typed variables>)

Where typed variables is a list of arguments defining the type and name of each variable:

<type|struct> <variable name>, ...

You can declare a new instance of type object using the new keyword, followed by the object name.

struct Person(
    string name,
    int age,
    string favouriteFood

storage Person me;

entry add(string name, int age, string food){ = new Person(, input.age,;

Struct variables can be accessed using a fullstop/dot - this can traverse recursively:

entry changeName(string name){ =;

Entry Points

Entry Points define the public calls that can be made to a smart contract written in fi. A smart contract can contain multiple entry points, each of which needs to be declared using the entry keyword followed by a name and optional input variables within a set of parenthesis. Input variables Input variables are a list of typed variables, similar to declaring a struct. This declaration can be blank, i.e. () .

<type|struct> <variable name>, ...

Input variables can then be accessed via the input variable:

input.<variable name>

*Note: At least one entry point must be defined for a contract to compile correctly.

entry add(string name, int age, string food){ = new Person(, input.age,;

Last updated