41 releases (18 stable)

4.1.1 Apr 17, 2024
4.0.2 Mar 14, 2024
4.0.0-rc.1 Dec 1, 2023
4.0.0-rc Nov 30, 2023
0.1.0 Oct 13, 2020

#1266 in Magic Beans

Download history 1433/week @ 2024-02-08 1387/week @ 2024-02-15 1464/week @ 2024-02-22 1891/week @ 2024-02-29 2338/week @ 2024-03-07 2814/week @ 2024-03-14 1458/week @ 2024-03-21 1237/week @ 2024-03-28 2060/week @ 2024-04-04 2983/week @ 2024-04-11 2089/week @ 2024-04-18 2576/week @ 2024-04-25 1817/week @ 2024-05-02 2119/week @ 2024-05-09 2249/week @ 2024-05-16 1005/week @ 2024-05-23

7,413 downloads per month
Used in 24 crates (11 directly)

Apache-2.0

41KB
925 lines

Contract Metadata

Defines types for the extended metadata of smart contracts targeting substrate.

Currently part of cargo-contract, the build tool for smart contracts written in ink!.


lib.rs:

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!["Parity Technologies <admin@parity.io>".to_string()])
    .description("increment a value".to_string())
    .documentation(Url::parse("http://docs.rs/").unwrap())
    .repository(Url::parse("http://github.com/paritytech/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();

Dependencies

~2.2–3.5MB
~96K SLoC