@standard-crypto/farcaster-js v7.4.0
Farcaster.js
A tool for interacting with the Farcaster social network.
Setup
Install the library:
npm install @standard-crypto/farcaster-js
Then grab a copy of the private key or mnemonic registered to your Farcaster user for use in authenticating to the platform. In the app, this can be found within settings -> Recovery Phrase
Examples
Publish a Cast
import { publishCast } from "@standard-crypto/farcaster-js";
import { Wallet } from "ethers";
const wallet = Wallet.fromMnemonic("twelve words here");
const cast = await publishCast(wallet, "Hello, Farcaster!");
console.log(`New cast hash: ${cast.hash}`);
Lookup a User
import { MerkleAPIClient } from "@standard-crypto/farcaster-js/merkleAPI";
import { Wallet } from "ethers";
const wallet = Wallet.fromMnemonic("twelve words here");
const client = new MerkleAPIClient(wallet);
// by farcaster ID ('fid')
await client.lookupUserByFid(3);
// by username
await client.lookupUserByUsername("dwr");
Fetch User Activity
import { MerkleAPIClient } from "@standard-crypto/farcaster-js";
import { Wallet } from "ethers";
// init
const wallet = Wallet.fromMnemonic("twelve words here");
const apiClient = new MerkleAPIClient(wallet);
// fetch handle to a user
const user = await apiClient.lookupUserByUsername("dwr");
if (user === undefined) throw new Error("no such user");
// fetch user's casts
for await (const cast of apiClient.fetchCastsForUser(user)) {
console.log(cast.text);
}
Reply to a Cast
import { MerkleAPIClient } from "@standard-crypto/farcaster-js";
import { Wallet } from "ethers";
// init
const wallet = Wallet.fromMnemonic("twelve words here");
const apiClient = new MerkleAPIClient(wallet);
// fetch cast to reply to
const user = await apiClient.lookupUserByUsername("dwr");
if (user === undefined) throw new Error("no such user");
const replyTo = await apiClient.fetchLatestCastForUser(user);
if (replyTo === undefined) throw new Error("no such user");
// post a reply
await apiClient.publishCast("Replying to your cast!", replyTo);
Documentation
Merkle API Client
The Merkle API is a collection of publicly exposed API endpoints provided by Merkle Manufactory, Inc
for Farcaster V2. farcaster-js
provides a set of typescript bindings for those endpoints, as well
as exposing the raw swagger bindings directly if needed.
See here for full list of the methods supported.
Hubs
Support for direct interaction with Farcaster hubs coming soon.
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago