Primitive

Introduction

The Primitive ADO is a smart contract that is used to store data. It is a simple contract that allows us to store key/value pairs acting like a database.

The Primitive ADO can be set to one of the following:

  • Private: Only accessible by the contract owner of the ADO.

  • Public: Accessible by anyone.

  • Restricted: Only accessible to the key owner.

You can add a fee for setting keys using our rates.

Ado_type: primitive

Version: 2.0.2-beta.1

InstantiateMsg

pub struct InstantiateMsg {
    pub restriction:PrimitiveRestriction,
    pub kernel_address: String,
    pub owner: Option<String>
}

PrimitiveRestriction

An enum defining the different types of restrictions that can be set.

pub enum PrimitiveRestriction {
    Private,
    Public,
    Restricted,
}
  • Private: Only accessible by the contract owner of the ADO.

  • Public: Accessible by anyone.

  • Restricted: Only accessible to the key owner (The address that first set the key).

ExecuteMsg

SetValue

Sets a value for the named key. When we need to extract the value that has been saved we would use the key.

If keyis not specified the default key ("default") will be used.

If SetValue uses a name that is already in use, the old value is overwritten by the latest value.

pub enum ExecuteMsg {
  SetValue {
        key: Option<String>,
        value: Primitive,
     }
  }

Primitive

An enum to specify the type of data you are saving.

pub enum Primitive {
    Uint128(Uint128),
    Decimal(Decimal),
    Coin(Coin),
    Addr(Addr),
    String(String),
    Bool(bool),
    Binary(Binary),
}

DeleteValue

Deletes the data attached to the specified key.

If key is not specified the default key ("default") will be used.

   pub enum ExecuteMsg{
   DeleteValue {
        key: Option<String>,
    }
 }

UpdateRestriction

Changes the restriction set on the primitive.

Only available to the contract owner.

pub enum ExecuteMsg {
 UpdateRestriction {
        restriction: PrimitiveRestriction,
    },
}

Rates

Sets a fee on adding values to the primitive.

Only available to the contract owner.

Only a Flat rate type is accepted.

You can read more here about setting rates.

Base Executes

The rest of the execute messages can be found in the ADO Base section.

QueryMsg

GetValue

Gets the value asociated to the specified key.

pub enum QueryMsg { 
 #[returns(GetValueResponse)]
    GetValue { key: Option<String> },
    }

GetValueResponse

pub struct GetValueResponse {
    pub key: String,
    pub value: Primitive,
}

AllKeys

Gets all the keys that are currently saved in the primitive ADO.

pub enum QueryMsg {
 #[returns(Vec<String>)]
    AllKeys {},
    }

Returns a Vec<String> containing all the available keys.

OwnerKeys

Gets all the keys that belong to the specified owner address.

pub enum QueryMsg {
    #[returns(Vec<String>)]
    OwnerKeys { owner: AndrAddr },
    }

Returns a Vec<String> containing all the keys belonging to the specified owner.

Base Queries

The rest of the query messages can be found in the ADO Base section.

Additional Resources

GithubWebsite