# Apps

Since AIN Blockchain is essentially a large public decentralized database, we have designed a concept of "Apps", where each app could represent a service or an organization.

## Registration

An App can be created and registered by setting app configs at `/manage_app/${appName}/create/${key}`. App configs include admin, billing, and service configs.&#x20;

#### Options

* \[boolean] is\_public: When is\_public option is set to `true`, the created app will allow anyone to set value and give branch\_owner, write\_function, and write\_rule owner permissions to anyone at the app's path (`/apps/${appName}`). Note that this option does not override the admin / billing / service configs, but sets additional permissions on top of the given configs.

## Configuration

### Admin Config

Admin config is a mapping of address and boolean (true), and if an address is added as an admin, upon the creation of the app, the address obtains all the owner permissions (branch\_owner, write\_function, write\_owner, write\_rule) as well as the write rule permission for the path `/apps/${appName}`.

```javascript
ain.db.ref(`/manage_app/${appName}/create/${Date.now()}`).setValue({
  admin: {
    "0xADDR_1": true,
    "0xADDR_2": true
  }
});
```

### Billing Config

The billing config specifies the names of the billing accounts associated with the app and the addresses that can use the billing accounts when sending transactions.

```javascript
ain.db.ref(`/manage_app/${appName}/create/${Date.now()}`).setValue({
  admin: {
    "0xADDR_1": true,
    "0xADDR_2": true
  },
  billing: {
    billingAccountA: {
      users: {
        "0xADDR_1": true,
        "0xADDR_2": true
      }
    },
    billingAccountB: {
      users: {
        "0xADDR_1": true,
        "0xADDR_3": true
      }
    }
  }
});
```

### Service Config

The service config contains service-specific configurations. For example, if the app uses a staking service, it could set the default lock-up duration by setting the config as follows:

```javascript
ain.db.ref(`/manage_app/${appName}/create/${Date.now()}`).setValue({
  admin: {
    "0xADDR_1": true,
    "0xADDR_2": true
  },
  billing: {
    billingAccountA: {
      users: {
        "0xADDR_1": true,
        "0xADDR_2": true
      }
    },
    billingAccountB: {
      users: {
        "0xADDR_1": true,
        "0xADDR_3": true
      }
    }
  },
  service: {
    staking: {
      lockup_duration: 2592000000 // ms
    }
  }
});
```

###


---

# Agent Instructions: 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:

```
GET https://docs.ainetwork.ai/ain-blockchain/ai-network-design/apps.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
