#smart-contracts #decode #json #serde #serde-json #decoder #type

ink_contract_decoder

A Rust crate to decode ink! contracts JSON into Rust types using Serde

2 releases

0.1.1 Mar 28, 2023
0.1.0 Mar 28, 2023

#245 in #serde-json

28 downloads per month

MIT license

6KB
106 lines

ink contract decoder

A Rust crate to decode ink! contracts JSON into Rust types using Serde.

Usage

Add this to your Cargo.toml:

[dependencies]
ink_contract_decoder = "0.1.0"

Example

use ink_contract_decoder::decode_ink_contract;

fn main() {
    let json_str = r#"
    {
        // Your JSON contract string here
    }
    "#;

    let ink_contract = decode_ink_contract(json_str).unwrap();
    println!("{:#?}", ink_contract);
}

lib.rs:

A library to decode ink! contract JSON into Rust types using Serde.

This crate provides a simple way to parse ink! contract JSON strings and deserialize them into Rust types for easy manipulation and interaction.

Example:

use ink_contract_decoder::decode_ink_contract;

fn main() {
    let json_str = r#"
    {
        // Your JSON contract string here
    }
    "#;

    let ink_contract = decode_ink_contract(json_str).unwrap();
    println!("{:#?}", ink_contract);
}

Dependencies

~0.8–1.7MB
~37K SLoC