Create Base Groups for Your Community
Group creation is exposed through Sdk::register_group(...).
The SDK will:
- pin the supplied profile through the profile service
- call the base-group factory
- return submitted transactions and, when possible, the predicted group avatar
Example: create a base group
use std::sync::Arc;
use alloy_primitives::address;
use circles_sdk::{EoaContractRunner, Sdk, config};
use circles_types::Profile;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let runner = Arc::new(
EoaContractRunner::connect(
"https://rpc.aboutcircles.com/",
"0xYOUR_PRIVATE_KEY",
)
.await?;
);
let sdk = Sdk::new(config::gnosis_mainnet(), Some(runner))?;
let owner = address!("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
let service = address!("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
let fee_collection = address!("cccccccccccccccccccccccccccccccccccccccc");
let profile = Profile {
name: "Neighborhood Group".into(),
description: Some("Local trading circle".into()),
preview_image_url: None,
image_url: None,
location: None,
geo_location: None,
extensions: None,
};
let registered = sdk
.register_group(
owner,
service,
fee_collection,
&[],
"Neighborhood",
"NBR",
&profile,
)
.await?;
println!("submitted {} tx(s)", registered.txs.len());
Ok(())
}