contractmeta!() { /* proc-macro */ }
Expand description
Adds a serialized SCMetaEntry::SCMetaV0 to the WASM contracts custom section under the section name ‘contractmetav0’. Contract developers can use this to append metadata to their contract.
§Examples
use soroban_sdk::{contract, contractimpl, contractmeta, vec, symbol_short, BytesN, Env, Symbol, Vec};
contractmeta!(key="desc", val="hello world contract");
#[contract]
pub struct HelloContract;
#[contractimpl]
impl HelloContract {
pub fn hello(env: Env, to: Symbol) -> Vec<Symbol> {
vec![&env, symbol_short!("Hello"), to]
}
}
#[test]
fn test() {
let env = Env::default();
let contract_id = env.register(HelloContract, ());
let client = HelloContractClient::new(&env, &contract_id);
let words = client.hello(&symbol_short!("Dev"));
assert_eq!(words, vec![&env, symbol_short!("Hello"), symbol_short!("Dev"),]);
}