AI Network
Search…
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.

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}.
1
ain.db.ref(`/manage_app/${appName}/create/${Date.now()}`).setValue({
2
admin: {
3
"0xADDR_1": true,
4
"0xADDR_2": true
5
}
6
});
Copied!

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.
1
ain.db.ref(`/manage_app/${appName}/create/${Date.now()}`).setValue({
2
admin: {
3
"0xADDR_1": true,
4
"0xADDR_2": true
5
},
6
billing: {
7
billingAccountA: {
8
users: {
9
"0xADDR_1": true,
10
"0xADDR_2": true
11
}
12
},
13
billingAccountB: {
14
users: {
15
"0xADDR_1": true,
16
"0xADDR_3": true
17
}
18
}
19
}
20
});
Copied!

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:
1
ain.db.ref(`/manage_app/${appName}/create/${Date.now()}`).setValue({
2
admin: {
3
"0xADDR_1": true,
4
"0xADDR_2": true
5
},
6
billing: {
7
billingAccountA: {
8
users: {
9
"0xADDR_1": true,
10
"0xADDR_2": true
11
}
12
},
13
billingAccountB: {
14
users: {
15
"0xADDR_1": true,
16
"0xADDR_3": true
17
}
18
}
19
},
20
service: {
21
staking: {
22
lockup_duration: 2592000000 // ms
23
}
24
}
25
});
Copied!