> For the complete documentation index, see [llms.txt](https://ola-foundation.gitbook.io/ola-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ola-foundation.gitbook.io/ola-lang/ola-language/contracts.md).

# Contracts

Contracts in Ola are similar to Solidity languages. Each contract can contain declarations of `State Variables`, `Functions`, `Events`, `Struct Types` and `Enum Types`.

There are also special kinds of contracts called `libraries` and `interface`.

The section about contracts contains more details than this section, which serves to provide a quick overview.

## State Variables

State variables are variables whose values are permanently stored in contract storage.

```solidity
contract SimpleStorage {
    u32 storedData; // State variable
    // ...
}
```

## Functions

Functions are the executable units of code. Functions are usually defined inside a contract.

```solidity
contract SimpleAuction {
    fn bid() { // Function
        // ...
    }
}
```

Functions accept `parameters` and `return` variables to pass parameters and values between them.

## Events

Events are convenience interfaces with the Ola logging facilities.

```solidity
contract SimpleAuction {
	event HighestBidIncreased(address bidder, u32 amount); // Event
    fn bid() {
        // ...
        emit HighestBidIncreased(original_address(), 1); // Triggering event
    }
}
```

## Struct Types

Structs are custom defined types that can group several variables

```solidity
contract Ballot {
    struct Voter { // Struct
        u32 weight;
        bool voted;
        address delegate;
        u32 vote;
    }
}
```

## Enum Types

Enums can be used to create custom types with a finite set of constant values

```solidity
contract Purchase {
    enum State { Created, Locked, Inactive } // Enum
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ola-foundation.gitbook.io/ola-lang/ola-language/contracts.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
