#blockchain #polka-vm #ink

contract-metadata

Library defining metadata for smart contracts on substrate

51 releases (24 stable)

Uses new Rust 2024

new 6.0.0-beta.1 Nov 13, 2025
6.0.0-alpha Mar 18, 2025
5.0.3 Jan 24, 2025
5.0.2 Dec 17, 2024
0.1.0 Oct 13, 2020

#4 in #ink

Download history 1006/week @ 2025-07-24 838/week @ 2025-07-31 748/week @ 2025-08-07 491/week @ 2025-08-14 732/week @ 2025-08-21 14308/week @ 2025-08-28 2056/week @ 2025-09-04 1335/week @ 2025-09-11 601/week @ 2025-09-18 1555/week @ 2025-09-25 1054/week @ 2025-10-02 1194/week @ 2025-10-09 1274/week @ 2025-10-16 1316/week @ 2025-10-23 3750/week @ 2025-10-30 3622/week @ 2025-11-06

10,121 downloads per month
Used in 29 crates (12 directly)

Apache-2.0

41KB
912 lines

Contract Metadata

Defines types for the extended metadata of ink! smart contracts targeting pallet-revive of Polkadot SDK.

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 contract_binary = SourceContractBinary::new(vec![0u8]);
// Optional information about how the contract was build
let build_info: Map<String, Value> = Map::new();
let source = Source::new(
    Some(contract_binary),
    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("useink/contracts-verifiable:6.0.0-beta");

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

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

Dependencies

~3–4.5MB
~79K SLoC