> For the complete documentation index, see [llms.txt](https://docs.ainetwork.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ainetwork.ai/ain-blockchain/ai-network-design/blockchain-database/states/operations.md).

# Operations

Blockchain state can be accessed using state access operations. There are two types of operations, *read operation* and *write operation*, and they are again classified into two categories: *simple operation* and *composite operation*. Simple operations are those that have only one access reference point (i.e., data path in the blockchain database), while composite operations have multiple access reference points.

## Read Operations

There is no permission required for read operations.

### Simple Operations

| Target   | Operator      | Parameters                     | Action                                               |
| -------- | ------------- | ------------------------------ | ---------------------------------------------------- |
| value    | GET\_VALUE    | ref                            | Get the value on the path reference                  |
| rule     | GET\_RULE     | ref                            | Get the rule config on the path reference            |
| owner    | GET\_OWNER    | ref                            | Get the owner config on the path reference           |
| function | GET\_FUNCTION | ref                            | Get a triggering function hash on the path reference |
| rule     | EVAL\_RULE    | ref, address, value, timestamp | Evaluate the rule config on the path reference       |
| owner    | EVAL\_OWNER   | ref, address                   | Evaluate the owner config on the path reference      |

### Composite Operations

| Target                          | Operator | Parameters                        | Action                                                                 | Rule requirements |
| ------------------------------- | -------- | --------------------------------- | ---------------------------------------------------------------------- | ----------------- |
| value, rule, owner, or function | GET      | op\_list (list of get operations) | Get multiple path-value, path-rule, path-owner, or path-function pairs | None              |

## Write Operations

Each write operation has permission requirements depending on its type and path reference.

### Simple Operations

| Target   | Operator      | Parameters    | Action                                             | Required Permission                   |
| -------- | ------------- | ------------- | -------------------------------------------------- | ------------------------------------- |
| value    | SET\_VALUE    | ref, value    | Set the value on the path reference                | Value write permission on the path    |
| value    | INC\_VALUE    | ref, value    | Increment the value on the path reference by delta | Value write permission on the path    |
| value    | DEC\_VALUE    | ref, value    | Decrement the value on the path reference by delta | Value write permission on the path    |
| rule     | SET\_RULE     | ref, rule     | Set the rule on the path reference                 | Rule write permission on the path     |
| owner    | SET\_OWNER    | ref, owner    | Set the owner on the path reference                | Owner write permission on the path    |
| function | SET\_FUNCTION | ref, funcHash | Set a triggering function on the path reference    | Function write permission on the path |

### Composite Operations

There are two composite write operations, SET and BATCH:

| Target                          | Operator | Parameters                          | Action                                                                 | Rule requirements                                 |
| ------------------------------- | -------- | ----------------------------------- | ---------------------------------------------------------------------- | ------------------------------------------------- |
| value, rule, owner, or function | SET      | op\_list (an array of operations)   | Set multiple path-value, path-rule, path-owner, or path-function pairs | Write permission on **all** the paths             |
| value, rule, owner, or function | BATCH    | tx\_list (an array of transactions) | Handle each transaction independently                                  | Write permission on the paths of each transaction |

The SET and BATCH operations can be compared as follows:

| Comparison | SET Operation                                                       | BATCH Operation                                                                                                              |
| ---------- | ------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| structure  | Has multiple operations in op\_list                                 | Has multiple transactions in tx\_list                                                                                        |
| atomicity  | The whole operation fails if one of the operation in op\_list fails | The transactions in tx\_list are executed independently, i.e., failure of one transaction does not affect other transactions |
| order      | Broadcasted in a bundle and executed in the given order             | Broadcasted in a bundle and executed in the given order                                                                      |


---

# 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://docs.ainetwork.ai/ain-blockchain/ai-network-design/blockchain-database/states/operations.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.
