Crate contract_metadata

Source
Expand description

Type definitions for creating and serializing metadata for smart contracts targeting Substrate’s contracts pallet.

§Example


let language = SourceLanguage::new(Language::Ink, Version::new(2, 1, 0));
let compiler =
    SourceCompiler::new(Compiler::RustC, Version::parse("1.46.0-nightly").unwrap());
let wasm = SourceWasm::new(vec![0u8]);
// Optional information about how the contract was build
let build_info: Map<String, Value> = Map::new();
let source = Source::new(
    Some(wasm),
    CodeHash([0u8; 32]),
    language,
    compiler,
    Some(build_info),
);
let contract = Contract::builder()
    .name("incrementer".to_string())
    .version(Version::new(2, 1, 0))
    .authors(vec!["Use Ink <ink@use.ink>".to_string()])
    .description("increment a value".to_string())
    .documentation(Url::parse("http://docs.rs/").unwrap())
    .repository(Url::parse("http://github.com/use-ink/ink/").unwrap())
    .homepage(Url::parse("http://example.com/").unwrap())
    .license("Apache-2.0".to_string())
    .build()
    .unwrap();
// user defined raw json
let user_json: Map<String, Value> = Map::new();
let user = User::new(user_json);
// contract abi raw json generated by contract compilation
let abi_json: Map<String, Value> = Map::new();
// image name and tag used for the verifiable build.
let image = String::from("paritytech/contracts-verifiable:3.0.1");

let metadata =
    ContractMetadata::new(source, contract, Some(image), Some(user), abi_json);

// serialize to json
let json = serde_json::to_value(&metadata).unwrap();

Modules§

byte_str
compatibility

Structs§

CodeHash
Representation of the Wasm code hash.
Contract
Metadata about a smart contract.
ContractBuilder
Builder for contract metadata
ContractMetadata
Smart contract metadata.
Source
Information about the contract’s Wasm code.
SourceCompiler
A compiler used to compile a smart contract.
SourceLanguage
The language and version in which a smart contract is written.
SourceWasm
The bytes of the compiled Wasm smart contract.
User
Additional user defined metadata, can be any valid json.

Enums§

Compiler
Compilers used to compile a smart contract.
Language
The language in which the smart contract is written.