7.4.0 • Published 1 year ago

@standard-crypto/farcaster-js v7.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Farcaster.js

NPM NPM GitHub Workflow Status

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.

7.4.0

1 year ago

7.3.1

1 year ago

7.3.0

1 year ago

7.2.0

1 year ago

7.1.1

1 year ago

7.1.0

1 year ago

6.0.0-alpha.3

2 years ago

6.0.0-alpha.4

2 years ago

6.0.0-alpha.5

2 years ago

6.0.0-alpha.1

2 years ago

6.0.0-alpha.2

2 years ago

6.0.1

2 years ago

6.0.0

2 years ago

6.0.3

2 years ago

6.0.2

2 years ago

7.0.0

2 years ago

5.7.0

2 years ago

5.6.0

2 years ago

5.5.4

2 years ago

5.5.3

2 years ago

5.5.2

2 years ago

5.5.1

2 years ago

5.5.0

2 years ago

5.4.0

2 years ago

5.3.0

2 years ago

5.2.0

3 years ago

5.1.0

3 years ago

5.0.0

3 years ago

5.0.0-beta.1

3 years ago

4.0.1

3 years ago

4.0.2

3 years ago

3.0.7

3 years ago

4.0.0-beta.2

3 years ago

3.0.6

3 years ago

4.0.0-beta.1

3 years ago

3.0.5

3 years ago

4.0.0

3 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago