Function provwasm_std::add_attribute
source · pub fn add_attribute<H: Into<Addr>, S: Into<String>, B: Into<Binary>>(
address: H,
name: S,
value: B,
value_type: AttributeValueType
) -> StdResult<CosmosMsg<ProvenanceMsg>>
Expand description
Create a message that will add an attribute (a typed key-value pair) to an account.
Example
// Imports required
use cosmwasm_std::{Binary, Env, Addr, Response, StdResult};
use provwasm_std::{add_attribute, AttributeValueType, ProvenanceMsg};
// Add a greeting attribute to an account.
// NOTE: The name below must resolve to the contract address.
fn exec_add_greeting(
env: Env,
address: Addr,
text: String,
) -> StdResult<Response<ProvenanceMsg>> {
let attr_name = String::from("greeting.my-contract.sc.pb");
let greeting = String::from("hello");
let msg = add_attribute(
address,
&attr_name,
Binary::from(greeting.as_bytes()),
AttributeValueType::String,
)?;
let mut res = Response::new().add_message(msg);
Ok(res)
}