| Crates.io | fatline-rs |
| lib.rs | fatline-rs |
| version | 0.2.2 |
| created_at | 2025-05-27 06:34:06.525174+00 |
| updated_at | 2025-06-03 18:00:21.042616+00 |
| description | Farcaster grpc client and utility library |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1690680 |
| size | 3,181,476 |
A library project to re-export some common Farcaster client RPC code and utilities, so that someone could interface with their own Farcaster Hub.
Users:
Hub info:
Streams:
Subscriptions:
Refactor everything to use the library specific types instead of relying on consumers to use the prost / protobuf types
Implement macros for a lot of the repeated functions to make improvements easier
Add the dependency to your project
# Cargo.toml
[dependencies.fatline-rs]
git = "https://github.com/0x330a-public/fatline-rs.git"
features = ["client"]
rev = "00aabbccdd..." # latest github commit while in early dev
(Maybe the protobuf dependencies are required for the build script I'm not sure):
nixpkgs: protobuf
Setting up the environment for authenticated calls:
use fatline_rs::{HubServiceClient, MessageTrait, SigningKey, VerifyingKey};
use fatline_rs::proto::{CastAddBody, FarcasterNetwork, HashScheme, Message, MessageData, MessageType, SignatureScheme};
use fatline_rs::proto::message_data::Body::CastAddBody as CABody;
use fatline_rs::utils;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut private_bytes: [u8; 32] = [0u8; 32];
hex::decode_to_slice("aabbccddeeff...", &mut private_bytes).unwrap();
let my_fid = 123456;
let key = SigningKey::from(private_bytes);
let mut client = HubServiceClient::connect("grpc://[some url or IP address]:2283").await?;
// ... use client / key in examples below ...
}
Updating your profile:
fn main () {
// ... setup ...
// Profile update using builder
let update = ProfileUpdateBuilder::create_empty()
.username_update(FieldUpdate::Add("username".to_string()))
.display_name_update(FieldUpdate::Add("Username".to_string()))
.bio_update(FieldUpdate::Remove)
// .github_update()
// .twitter_update()
// .location_update()
// .url_update()
// .profile_pic_update()
.build()?;
}
Making a post:
fn main() {
// ... setup ...
// Construct the cast creation using a builder
let update = CastCreateBuilder::create_empty()
.body("@Farcaster cool cast".to_string())
// .parent(Parent::CastId(etc)
// .embeds(vec![Embed::Url("https://something.com".to_string())])
// .mentions(vec![Mention { fid: 1, start_pos: 0 }])
.build()?;
let result = client.submit_bulk_messages(update.to_messages(my_fid, &key)).await?;
println!("{:?}", result);
}
Firstly, create an ed25519 Signing key if you don't have the bytes already to create one: (You can also use jesse for this)
use fatline_rs::utils::generate_signing_key;
fn main() {
// *****INITIAL SETUP*****
// 1. generate a signing key
let key = generate_signing_key();
// 2. print out the hex encoded bytes here to re-use the same key
println!("keep this one secret: {}", hex::encode(key.as_bytes()));
// 3. add the signing key to your farcaster account
// open this in browser, just easier to highlight this way
let verifying_key = VerifyingKey::from(&key);
println!("publish this one in dashboard: {}", hex::encode(verifying_key.as_bytes()));
let dashboard_url = "https://terminex.mempool.online";
// connect registered farcaster wallet -> add key -> paste hex output of verifying key ^ -> submit tx
// ************************
// 4. disregard the above lines and re-build your key from saved output from first run
let mut private_bytes: [u8; 32] = [0u8; 32];
hex::decode_to_slice("aabbccddeeff...", &mut private_bytes).unwrap();
}