Andromeda
Search
⌃K

App

Introduction

The App ADO is a smart contract that is used to bundle up contracts that will be interacting with each other into what we call an "App" and would provide a naming system to allow these contracts to reference each other using these names instead of contract addresses. Essentially, an App would include several contracts that interact to complete a desired goal for the project being built.
A contract in the App is called a AppComponent. Every app would be composed of many of these components (up to 50). Each component is assigned a name which can be used by other components to reference each other.
To build a full app from scratch we only need to instantiate the app contract and attach a primitive to it (primitive_contract field in instantiation). This primitive contains a reference to an "ado db" ADO which has all the ADO code Ids saved. These contracts are already deployed to chain and the addresses can be found in our deployed contracts section. You can learn to deploy your first app here.
Ado_type: app

InstantiateMsg

The maximum number of app components is 50.
Rust
JSON
pub struct InstantiateMsg {
pub app_components: Vec<AppComponent>,
pub name: String,
pub primitive_contract: String
}
{
"app_components":[
{
"name":"fundsplitter",
"ado_type":"splitter",
"instantiate_msg":"eyJtaW50ZXIiOiAianVubzE3OX..."
},
{
...
}
],
"name":"some_app",
"primitive_contract":"andr1..."
}
Name
Type
Description
app_components
The vector of AppComponent containing all the ADOs of the app.
name
String
The name of the app.
primitive_contract
String
The address of the primitve contract used to supply data to the app.

AppComponent

The ADO to be a part of the App.
The instantiate_msg should be base64 encoded and not raw binary.
The name field is case sensitive.
pub struct AppComponent {
pub name: String,
pub ado_type: String,
pub instantiate_msg: Binary,
}
Name
Type
Description
name
String.
The name of the ADO component. The names can be used later on to reference the coponent.
ado_type
String
The type of the ADO.
instantiate_msg
Binary
The instantiate message of the ADO component in base64 binary.

ExecuteMsg

AddAppComponent

Adds an ADO component to the app.
Only available to the contract owner.
Rust
JSON
pub enum ExecuteMsg {
AddAppComponent{
component: AppComponent,
}
}
{
"add_app_component":{
"component":{
"name":"crowdfund",
"ado_type":"crowdfund",
"instantiate_msg":"eyJ0b2tlbl9hZGRyZXNzIjp7ImlkZW50aWZpZXIiOiJqdW5vMS4uLiJ9InByaW1pdGl2ZV9hZGRyZXNzIjoianVubzEuLi4sImNhbl9taW50X2FmdGVyX3NhbGUiOiB0cnVlfQ=="
}
}
Name
Type
Description
component
The ADO component to add to the app.

ClaimOwnership

Gives ownership of a component to the owner address instead of the app contract.
Only available to the contract owner.
Rust
JSON
pub enum ExecuteMsg{
ClaimOwnership {
name: Option<String>
}
}
{
"claim_ownership":{
"name":"mycomponent"
}
}
Name
Type
Description
name
Option<String>
Optional name for the component to claim. If not set, will claim all ADO components in the app.

ProxyMessage

Sends a message to the ADO with the specified name. This is used in the case the app contract has specific operation privileges over a component.
Only available to the contract owner.
Rust
JSON
pub enum ExecuteMsg{
ProxyMessage {
name: String,
msg: Binary
}
}
{
"proxy_message":{
"name":"componentname",
"msg":"eyJtaW50Ijp7InRva2VuX2lkIjo..."
}
}
Name
Type
Description
name
String
The name of the ADO to execute on.
msg
Binary
The msg to excecute (Base 64 binary).

UpdateAddress

Sets a new contract address for the ADO with the specified name.
Rust
JSON
pub enum ExecuteMsg {
UpdateAddress {
name: String,
addr: String
}
}
{
"update_address":{
"name":"componentname",
"addr":"andr1..."
}
}
Name
Type
Description
name
String
The name of the ADO.
addr
String
The new contract address for the ADO.

AndrReceive

The rest of the executes can be found in the AndrReceive section.

QueryMsg

GetAddress

Queries the contract address of a component name.
Rust
JSON
pub enum QueryMsg{
#[returns(String)]
GetAddress { name: String }
}
{
"get_address":{
"name":"componentname"
}
}
Name
Type
Description
name
String
The name of the component to get the contract address for.
Returns a String of the component address.

GetAddressesWithNames

Queries all the components returning the name along with the address for each.
Rust
JSON
pub enum QueryMsg {
#[returns(Vec<ComponentAddress>)]
GetAddressesWithNames {}
}
{
"get_addresses_with_names":{}
}

ComponentAddress

Rust
JSON
pub struct ComponentAddress {
pub name: String,
pub address: String,
}
{
"name":"token",
"address":"andr1..."
}

GetComponents

Rust
JSON
pub enum QueryMsg{
#[returns(Vec<AppComponent>)]
GetComponents {}
}
{
"get_components":{}
}
Returns a Vec<AppComponent> which contains all the components of the app.

Config

Queries the configuration of the app.
Rust
JSON
pub enum QueryMsg{
#[returns(ConfigResponse)]
Config {}
}
{
"config":{}
}

ConfigResponse

Rust
JSON
pub struct ConfigResponse {
pub owner: String,
pub name: String,
}
{
"name":"myapp",
"owner":"andr1..."
}

ComponentExists

Checks if a component with the specified name exists.
Rust
JSON
pub enum QueryMsg {
#[returns(bool)]
ComponentExists { name: String },
}
{
"component_exists":{
"name":"mycomponent"
}
}
Name
Type
Description
name
String
The name of the component to check.
Returns a bool response.

AndrQuery

pub enum QueryMsg {
AndrQuery(AndromedaQuery),
}
If the AndromedaQuery is of type Get , the contract will query address of the specified name (data) . If no data is supplied in the Get, an error will occur.
fn handle_andromeda_query(
deps: Deps,
env: Env,-
msg: AndromedaQuery,
) -> Result<Binary, ContractError> {
match msg {
AndromedaQuery::Get(data) => match data {
None => Err(ContractError::ParsingError {
err: String::from("No data passed with AndrGet query"),
}),
Some(_) => {
//Default to get address for given ADO name
let name: String = parse_message(&data)?;
encode_binary(&query_component_address(deps, name)?)
}
},
_ => ADOContract::default().query(deps, env, msg, query),
}
}
Check AndrQuery for the rest of the base queries.
Base queries are common for all Andromeda ADOs.