Andromeda
Search…
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.
The steps needed to build a full app from scratch are the following:
  1. 1.
    Upload the contracts and get the code IDs.
  2. 2.
    Instantiate a factory contract and save the code IDs of the contracts in it.
  3. 3.
    Instantiate a primitive contract and save the factory address as a value under the name "factory".
  4. 4.
    Instantiate the app contract and attach the primitive to it (primitive_contract field in instantiation)
Andromeda has a list of deployed addresses that include the Factory with the code ids of all the contracts and a primitive linked to it. This means that the first three steps are already covered if you use our deployed contracts. All that is needed is step 4. 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: Vec<AppComponent>,
pub name: String,
pub primitive_contract: String
}
{
"app":[
{
"name":"fundsplitter",
"ado_type":"splitter",
"instantiate_msg":"eyJtaW50ZXIiOiAianVubzE3OX..."
},
{
...
}
],
"name":"some_app",
"primitive_contract":"juno1..."
}
Name
Type
Description
App
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.
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.
ado_type
String
The type of the ADO.
instantiate_msg
Binary
The instantiate message of the ADO component.

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":"fundsplitter",
"ado_type":"splitter",
"instantiate_msg":{
...
}
}
}
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":"eyJtaW50ZXIiOiAianVubzE3OX..."
}
}
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":"juno1..."
}
}
Name
Type
Description
name
String
The name of the ADO.
addr
String
The new contract address for the ADO.

AndrReceive

QueryMsg

GetAddress

Queries the contract address of a component name.
Rust
JSON
pub enum QueryMsg{
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.

GetAddresses

Rust
JSON
pub enum QueryMsg{
GetAddresses {}
}
{
"get_addresses":{}
}
Returns a Vec<ComponentAddress> containing the name and address of each component.

ComponentAddress

Rust
JSON
pub struct ComponentAddress {
pub name: String,
pub address: String,
}
{
"name":"componentname",
"address":"juno1..."
}

GetComponents

Rust
JSON
pub enum QueryMsg{
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{
Config {}
}
{
"config":{}
}

ConfigResponse

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

ComponentExists

Checks if a component with the specified name exists.
Rust
JSON
pub enum QueryMsg {
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 default queries.
Copy link
Outline
Introduction
InstantiateMsg
AppComponent
ExecuteMsg
AddAppComponent
ClaimOwnership
ProxyMessage
UpdateAddress
AndrReceive
QueryMsg
GetAddress
GetAddresses
GetComponents
Config
ComponentExists
AndrQuery