For the complete documentation index, see llms.txt. This page is also available as Markdown.

Ola Language ABI

In order to interact programmatically with compiled ola programs, Ola language supports passing arguments using an ABI.

To illustrate this, we'll use the following example program:


contract BookExample {
    struct Book {
        u32 book_id;
        string book_name;
    }

    fn createBook(u32 id, string name) -> (Book) {
        Book myBook = Book({
            book_name: name,
            book_id: id
        });
        return myBook;
    }

    fn getBookName(Book _book) -> (string) {
        return _book.book_name;
    }

    fn getBookId(Book _book) -> (u32) {
        u32 b = _book.book_id + 1;
        return b;
    }

}

ABI specification

When compiling a ola program, an ABI specification is generated and describes the interface of the program.

In this example, the ABI specification is:

ABI encode function and params

We can use the tools provided by ola-lang-abi to generate function selectors and function parameters corresponding to ABI.

https://github.com/Sin7Y/ola-lang-abi/tree/main/examples

Last updated