Crates.io | freechains |
lib.rs | freechains |
version | 0.3.1 |
source | src |
created_at | 2021-10-29 20:54:01.66114 |
updated_at | 2021-11-19 23:44:40.438862 |
description | Freechains client library for rust. |
homepage | https://github.com/lrabbt/freechains-rs |
repository | https://github.com/lrabbt/freechains-rs |
max_upload_size | |
id | 474188 |
size | 60,564 |
A Freechains client rust library.
Compatible with Freechains server version v0.9.0
.
freechains-rs
is intended as a simple Freechains client interface for rust development.
List all server chains.
use freechains::{Client, ClientError};
fn main() -> Result<(), ClientError> {
let mut client = Client::new("0.0.0.0:8330");
let chain_ids = client.chains()?;
Ok(())
}
Join and post on a public chain.
use freechains::{Client, ChainId, ClientError};
fn main() -> Result<(), ClientError> {
let mut client = Client::new("0.0.0.0:8330");
// Join public chain
let chain_id = ChainId::new("#forum")?;
let chain_pubkey1 = "some_known_key1";
let chain_pubkey2 = "some_known_key2";
client.join_chain(&chain_id, &[chain_pubkey1, chain_pubkey2])?;
// Generate public and private keys
let (pubkey, pvtkey) = client.crypto_pubpvt("strong_password")?;
let mut chain_client = client.chain(&chain_id);
// Post on public chain
chain_client.post(Some(&pvtkey), false, b"Hello, forum!")?;
Ok(())
}
MIT