SDK Reference

@tribe-protocol/sdk is the single TypeScript entry point for everything — identity, social graph, content, payments, and direct Anchor calls.

Install

npm install @tribe-protocol/sdk @coral-xyz/anchor @solana/web3.js

TribeClient

Construct one of the three preset clients — they ship with the right program IDs and hub URLs baked in.

import { TribeClient } from "@tribe-protocol/sdk";
import { AnchorProvider } from "@coral-xyz/anchor";

const provider = new AnchorProvider(connection, wallet, { commitment: "confirmed" });

const tribe = TribeClient.forDevnet(provider);
// or: TribeClient.forMainnet(provider) / TribeClient.forLocalnet(provider)

// Identity
const { tid } = await tribe.identity.tid.register(recoveryAddress);
await tribe.identity.appKeys.addAppKey(tid, appPubkey, AppKeyScope.Full);
await tribe.identity.usernames.register(tid, "alice");

// Social
await tribe.social.follow(myTid, targetTid);
await tribe.tweets.publish(myTid, "gm from the mesh", appKey);

Hub-backed modules

Each of these speaks to the hub's REST API and signs envelopes locally with your app key. The hub validates signatures against the on-chain app-key record.

tribe.social

Follow / unfollow with ER fast-path and direct-Solana fallback.

tribe.tweets

Publish signed posts and read the feed.

tribe.dms

End-to-end encrypted DMs with NaCl box ciphertexts.

tribe.channels

Topic channels with first-registration ownership on-chain.

tribe.bookmarks

Per-TID bookmarks of any signed message hash.

tribe.polls

One-vote-per-TID polls with an 8-slot tally.

tribe.events

RSVPable events with optional lat/lng.

tribe.tasks

Local tasks with optional on-chain reward escrow.

tribe.crowdfunds

Campaigns with pledge / claim / refund flows.

tribe.tips

Off-chain receipts that mirror on-chain SOL tips.

tribe.search

Full-text search over content the hub has indexed.

tribe.stories

Ephemeral 24-hour stories (Phase 3 of tribe-insta).

tribe.userData

Display name, bio, avatar, and other profile metadata.

On-chain Anchor clients

For features that involve lamport transfers, escrow, or voting integrity, the SDK exposes raw Anchor program clients under tribe.onchain.* — distinct from the hub-backed modules above.

tribe.onchain.tips

Anchor program calls for on-chain SOL tip receipts.

tribe.onchain.crowdfunds

Direct escrow account management.

tribe.onchain.tasks

On-chain reward escrow for task posters.

tribe.onchain.channels

First-registration channel slug claims.

tribe.onchain.karma

Trustless karma reads from tip + task proofs.

tribe.onchain.polls

Optional fully-on-chain poll storage.

tribe.onchain.events

Event accounts with lat/lng + RSVP counters.

Execution Providers

tribe.social is the only module that goes through an ExecutionProvider — defaults to DirectSolanaProvider. Swap it for the ER provider to get sub-50 ms follow confirmations.

import { TribeClient, EphemeralRollupProvider } from "@tribe-protocol/sdk";

const tribe = TribeClient.forDevnet(provider, {
  execution: new EphemeralRollupProvider({
    erServerUrl: "http://localhost:3003",
    custodyPubkey: wallet.publicKey.toBase58(),
    signFn: (msg) => wallet.signMessage(msg),
  }),
});

// Instant follow — settles to L1 within 10s
await tribe.social.follow(myTid, targetTid);
If the ER server is unreachable, follows transparently fall back to direct L1 transactions. The ER is a convenience layer, never a gatekeeper.