farcaster-hub-utils
v0.1.9
Published
Class to use a signer key for doing hub actions.
Downloads
10
Maintainers
Readme
farcaster-hub-utils - 0.1.9
Simple library to simplify the interaction with the Farcaster Hub. Works with a private an authorized signer key and account fid.
Basic Usage
import { FcHubUtils } from 'farcaster-hub-utils';
import { PK, FID, HUB_URL, HUB_USER, HUB_PASS } from './secret';
const fcHubUtils = new FcHubUtils(PK, FID, HUB_URL?, HUB_USER?, HUB_PASS?);
// Invoke some interaction with the hub
const castText = 'Hello World!';
fcHubUtils.createFarcasterPost({
content: castText,
})
Available Methods
Methods user should use
createFarcasterPost
- Create a new castcreateCast
- Alias forcreateFarcasterPost
deleteCast
- Delete a castgetCastsByFid
- Get casts for feed in a specific time range, time range can be used to paginatechangeHub
- Change The instance to use a different hub (useful for balancing)changeSigner
- Change The instance to use a different signer (useful to switch between accounts and conserve memory)addLike
- Add a like to a castremoveLike
- Remove a like from a castaddRecast
- Add a recast to a castremoveRecast
- Remove a recast from a castgetFidFromUsername
- Get the fid from a username
Internal Methods ( lower level )
publishCast
- Publish a cast to the hubbyteLength
- Get the byte length of a stringparseEmbeds
- Parse embeds from a string as { url: string }[]parseFarcasterMentions
- Parse mentions from a string as { mentions, mentionsPositions, mentionsText }addReaction
- Lower level method to add a reaction to a castremoveReaction
- Lower level method to remove a reaction from a cast
Changelog
Notes
- The
PK
is the private key of the signer. - The
FID
is the account fid. - HUB_URL, HUB_USER, HUB_PASS are optional parameters to connect to the hub, if not provided, an public hub will be used.
- creating cast methods support, posting to channels, and replying to posts and post media if you have supported media public urls.
Upcoming Features
- add more features
- add more tests