Skip to content

Latest commit

 

History

History
195 lines (142 loc) · 8.29 KB

README.md

File metadata and controls

195 lines (142 loc) · 8.29 KB

fc — Snapchain CLI

ALPHA. Flags, subcommand names, output format, and error semantics may change without notice. Don't depend on it from scripts you care about, and don't point it at mainnet without reading what each subcommand actually does.

fc is a small command-line client for submitting Farcaster messages to a Snapchain node and streaming HubEvents from it. It is shipped as a second binary inside the official Snapchain Docker image, so the proto version baked into fc always matches the node binary in the same image tag.

Subcommands

Subcommand What it does
key-add Submit a gasless KEY_ADD (FIP-272). Generates a fresh signer by default.
key-remove Submit a KEY_REMOVE, either custody-signed or self-revoke.
cast-add Submit a CAST_ADD signed by an existing Ed25519 key.
cast-remove Submit a CAST_REMOVE signed by an existing Ed25519 key.
link Submit LINK_ADD / LINK_REMOVE / LINK_COMPACT_STATE — follows and blocks.
live-at Submit USER_DATA_ADD of type LIVE_AT (FIP-268 presence heartbeat).
verification Submit VERIFICATION_ADD_ETH_ADDRESS / VERIFICATION_REMOVE.
devnet Devnet-only AdminService helpers. Registers FIDs on a local node.
subscribe Stream HubEvents from a snapchain gRPC node and log them as JSON to stdout.

Run fc <subcommand> --help for the full flag list.

Running it

The recommended way to run fc is out of the snapchain Docker image. The image tag determines which proto version fc was built against — see Versioning below.

docker run --rm farcasterxyz/snapchain:<version> ./fc --help

Example: stream HubEvents from a public testnet node:

docker run --rm farcasterxyz/snapchain:<version> \
  ./fc subscribe --shard 1 --grpc-node https://iris.farcaster.xyz:3383

Example: submit a CAST_ADD against the default HTTP endpoint:

docker run --rm -e SIGNER_SECRET=0x... farcasterxyz/snapchain:<version> \
  ./fc cast-add --fid 123 --text "hello snapchain"

If you already have a snapchain node running in a container, you can docker exec instead:

docker exec <node-container> ./fc subscribe --shard 1 --grpc-node http://localhost:3383

Building from source

For local development, fc is a normal cargo workspace member:

cargo build --release -p fc-cli --bin fc
./target/release/fc --help

Links: follows and blocks

fc link submits the three link message types. A link is directional: --fid is the author, --target-fid is the FID being followed or blocked. --type defaults to follow.

Follow FID 456 as FID 123, then unfollow:

export SIGNER_SECRET=0x...

fc link add    --fid 123 --target-fid 456
fc link remove --fid 123 --target-fid 456

Block and unblock — same shape, --type block:

fc link add    --fid 123 --target-fid 456 --type block
fc link remove --fid 123 --target-fid 456 --type block

Follows and blocks are stored under separate link types, so the same pair can be both at once. To watch the resulting MERGE_MESSAGE events land, run fc subscribe on the author's shard in another terminal:

fc subscribe --shard 1 --event-types merge-message

follow and block are the well-known types, but the node bounds --type at 1–8 bytes and keeps no allowlist, so any short string is accepted:

fc link add --fid 123 --target-fid 456 --type mytype

If your signer is a gasless key (fc key-add), it needs the matching scope — link-add, link-remove, or link-compact-state — or the node rejects the message as out of scope. fc key-add grants all scopes unless you pass --scopes.

Compact state

LINK_COMPACT_STATE replaces the author's entire link set for one type with the listed targets. Any target of that type not listed is dropped — this compacts 3 follows down to 2:

fc link compact-state --fid 123 --target-fids 456,789 --type follow

Compaction is only type-scoped from engine V19 (ProtocolFeature::BlockLinks) onward. Before V19, compaction is type-blind: a --type follow compact state also deletes the author's blocks. V19 is live on testnet (activated 2026-07-15 14:00 UTC) and activates on mainnet 2026-07-27 14:00 UTC. Until then, a follow compaction on mainnet will silently wipe blocks.

Versioning

fc --version prints both its own version and the snapchain-proto version it was compiled against. The proto version is the one that determines wire compatibility with a snapchain node.

$ fc --version
fc 0.1.0
snapchain-proto 0.11.0

Because fc is distributed inside the snapchain Docker image, the simplest compatibility rule is: use the fc from the same image tag as the node you're talking to. A given farcasterxyz/snapchain:X.Y.Z always ships fc built against the proto version that node uses.

The CLI version in cli/Cargo.toml is independent of the snapchain release version and only bumps when the CLI's own flag/output surface changes meaningfully. The proto compatibility guarantee comes from the image tag, not the CLI version.

JSON output shape

fc subscribe serializes events using the Serde derives that tonic-build emits on the proto types. This is a thinner shape than the hub-API JSON returned by snapchain's HTTP server: field names are prost defaults (snake_case), and enums are emitted as variant strings. If you need the exact hub-API shape, query the snapchain HTTP server directly. This may change in a future release; pin a specific image tag if you're parsing the output programmatically.

Verifications

verification add proves an Ethereum EOA belongs to a FID. The claim is EIP-712 typed data binding (fid, address, blockHash, network), signed by the address being verified — so --wallet-secret has to be that address's real key, not the FID's. The node recovers the signer and rejects the message unless it matches.

fc --node http://127.0.0.1:3483 --network devnet verification add \
  --fid 200001 --wallet-secret 0x<secp256k1-secret> --signer-secret 0x<ed25519-secret>

fc --node http://127.0.0.1:3483 --network devnet verification remove \
  --fid 200001 --address 0x<20-byte-address> --signer-secret 0x<ed25519-secret>

--wallet-secret may be omitted to derive the address from MNEMONIC at --path instead. --block-hash defaults to random bytes; devnet does not check it against a real block.

Only EOA verifications are supported. Contract-signature verifications (type: 1) are validated by the node against a chain RPC outside the consensus loop, which a devnet has no endpoint for.

Devnet bootstrap

A fresh devnet has no registered FIDs, and nothing merges without one. devnet bootstrap submits the three on-chain events a usable FID needs — storage rent, ID-register, and a signer — straight to the AdminService:

fc devnet bootstrap --grpc-node http://127.0.0.1:3383 --auth dev:dev \
  --fid 200001 --count 60 --signer-secret 0x<ed25519-secret>

It prints each FID's signer secret (and generates one per FID if --signer-secret is omitted). On-chain events are applied asynchronously, so give the node a few blocks before submitting messages. --auth must match the node's admin_rpc_auth; the devnet Docker image bakes in dev:dev.

This is devnet-only by construction: the events are synthetic, and any real network decodes them from a chain instead.

Environment variables

Variable Used by Description
SIGNER_SECRET cast-add, cast-remove, link, live-at, key-add, key-remove, verification, devnet bootstrap Hex-encoded Ed25519 secret (32 bytes, optional 0x prefix).
MNEMONIC key-add, key-remove (custody), verification add BIP-39 mnemonic for the custody-key derivation path.
WALLET_SECRET verification add Hex secp256k1 secret for the address being verified.