cainome-rs

Crates.iocainome-rs
lib.rscainome-rs
version0.5.0
created_at2025-02-07 02:31:45.732273+00
updated_at2025-09-03 16:33:48.954839+00
descriptionA run-time library to generate rust bindings for cairo contracts.
homepagehttps://github.com/cartridge-gg/cainome
repositoryhttps://github.com/cartridge-gg/cainome
max_upload_size
id1546452
size115,508
(glihm)

documentation

https://github.com/cartridge-gg/cainome

README

Cainome Rust backend

This crates contains the run-time library to generate rust bindings (using Cairo Serde).

This crate is used as built-in plugin of cainome CLI, and is mainly published to expose the library used by abigen! macro in cainome-rs-macro crate.

For more details on what's generated, check the rs-macro README.

This crate however exposes a Abigen struct that can be used to programmatically generate bindings for a contract.

Example

use cainome::rs::Abigen;
use std::collections::HashMap;

#[tokio::main]
async fn main() {
    let mut aliases = HashMap::new();
    aliases.insert(String::from("my::type::Event"), String::from("MyTypeEvent"));

    let abigen = Abigen::new(
        "MyContract",
        "./contracts/target/dev/contracts_simple_get_set.contract_class.json",
    )
    .with_types_aliases(aliases)
    .with_derives(vec!["Debug".to_string(), "PartialEq".to_string()])
    .with_contract_derives(vec!["Debug".to_string(), "Clone".to_string()]);

    abigen
        .generate()
        .expect("Fail to generate bindings")
        .write_to_file("/tmp/abigen.rs")
        .unwrap();
}
Commit count: 189

cargo fmt