| Crates.io | circles-abis |
| lib.rs | circles-abis |
| version | 0.1.0 |
| created_at | 2025-12-05 12:09:25.44352+00 |
| updated_at | 2025-12-05 12:09:25.44352+00 |
| description | Circles contract ABIs and bindings |
| homepage | https://circles-rs-book.vercel.app/ |
| repository | https://github.com/deluXtreme/circles-rs |
| max_upload_size | |
| id | 1968064 |
| size | 181,291 |
Contract ABI definitions for all Circles protocol smart contracts.
This crate provides type-safe Rust bindings for all Circles smart contracts using the alloy-sol-types framework. Each contract module contains the complete ABI definition and generated Rust types for seamless contract interaction.
The abis crate serves as the contract interface layer for the Circles protocol, providing:
alloy ecosystem for contract callsAdd this to your Cargo.toml:
[dependencies]
abis = "0.1.0"
This crate includes ABI definitions for:
BaseGroup - Base group contract functionalityBaseGroupFactory - Factory for creating base groupsDemurrageCircles - Demurrage-based personal currency tokensHubV2 - Main Circles V2 protocol hubInflationaryCircles - Inflationary personal currency tokensInvitationEscrow - Escrow system for invitationsInvitationFarm - Farming mechanism for invitationsLiftERC20 - ERC20 wrapper functionalityNameRegistry - Name registration systemReferralsModule - Referral system moduleuse abis::{HubV2, BaseGroup, NameRegistry};
use alloy_primitives::Address;
// Use with alloy providers
let hub_address: Address = "0x...".parse()?;
let contract = HubV2::new(hub_address, provider);
// Call contract methods
let result = contract.isHuman(user_address).call().await?;
All contracts are generated using alloy-sol-types and provide:
use abis::HubV2;
use alloy_primitives::Address;
use alloy_provider::Provider;
async fn check_human(
provider: impl Provider,
hub_address: Address,
user: Address
) -> Result<bool, Box<dyn std::error::Error>> {
let hub = HubV2::new(hub_address, provider);
let is_human = hub.isHuman(user).call().await?._0;
Ok(is_human)
}
use abis::HubV2;
use alloy_primitives::Address;
// Listen for trust events
let filter = hub.Trust_filter().watch().await?;
let mut stream = filter.into_stream();
while let Some(log) = stream.next().await {
match log {
Ok((event, log_meta)) => {
println!("Trust event: {} trusts {} until {}",
event.user, event.trusted, event.expiryTime);
}
Err(e) => eprintln!("Error: {}", e),
}
}
Each contract follows a consistent structure:
contract_name/
├── mod.rs # Contract ABI and generated types
└── contract_name.json # Original ABI JSON file
The sol! macro generates all necessary types and methods from the JSON ABI:
use alloy_primitives::{Address, B256, Bytes, U256};
use alloy_provider::{Provider, ProviderBuilder};
use alloy_sol_types::{SolCall, sol};
sol!(
HubV2,
"src/hub_v2/hub_v2.json"
);
When using these contracts, you'll need the deployed contract addresses for your target network:
Refer to the Circles documentation for current contract addresses.
Contract calls can fail for various reasons. The generated contracts provide typed errors:
use abis::HubV2;
match hub.trust(trustee, expiry_time).call().await {
Ok(result) => println!("Trust established successfully"),
Err(e) => {
if let Some(revert) = e.as_revert() {
println!("Contract reverted: {}", revert);
} else {
println!("Other error: {}", e);
}
}
}
This crate works seamlessly with:
alloy-primitives - For Ethereum types (Address, U256, etc.)alloy-provider - For blockchain connectivityalloy-contract - For contract interaction patternscircles-types - For higher-level Circles protocol typesTo add a new contract ABI:
src/new_contract/src/new_contract/new_contract.jsonsrc/new_contract/mod.rs with the sol! macrosrc/lib.rsWhen contract ABIs change:
Licensed under either of
MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)