| Crates.io | cainome-rs |
| lib.rs | cainome-rs |
| version | 0.5.0 |
| created_at | 2025-02-07 02:31:45.732273+00 |
| updated_at | 2025-09-03 16:33:48.954839+00 |
| description | A run-time library to generate rust bindings for cairo contracts. |
| homepage | https://github.com/cartridge-gg/cainome |
| repository | https://github.com/cartridge-gg/cainome |
| max_upload_size | |
| id | 1546452 |
| size | 115,508 |
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.
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();
}