Builders
Builders are factory methods that construct and sign Farcaster Messages which can be broadcast to Hubs.
Prerequisites
Before you can build messages, you'll need construct the following objects:
- An
ed25519Signer, used to sign most messages.
- A
eip712Signer, used to sign some messages.
- A
dataOptions, which contains message metadata.
Ed25519Signer
A Ed25519Signer is an EdDSA key pair which is necessary for signing most messages on behalf of an fid. This example below shows how to construct a new Ed25519Signer using the @noble library :
Eip712Signer
An Eip712Signer is an ECDSA key pair which is necessary signing for some messages like SignerAdds and Verifications. This example shows how to construct an Eip712Signer from a wallet's recovery phrase:
Data Options
A DataOptions object tells the factory some metadata about the message. This example shows how to create the dataOptions object to pass to the Factory:
Builder Methods
makeSignerAdd
Returns a message which authorizes a new Ed25519 Signer to create messages on behalf of a user.
Usage
Returns
| Type |
Description |
HubAsyncResult<SignerAddMessage> |
A HubAsyncResult that contains the valid SignerAddMessage. |
Parameters
| Name |
Type |
Description |
body |
SignerBody |
A valid VerificationAddEd25519 body object containing the data to be sent. |
dataOptions |
MessageDataOptions |
Optional arguments to construct the message. |
signer |
Eip712Signer |
An Eip712Signer generated from the user's custody address. |
makeSignerRemove
Returns a message which revokes a previously authorized Ed25519 Signer.
Usage
Returns
| Type |
Description |
HubAsyncResult<SignerRemoveMessage> |
A HubAsyncResult that contains the valid SignerRemoveMessage. |
Parameters
| Name |
Type |
Description |
body |
SignerBody |
A valid SignerRemove body object containing the data to be sent. |
dataOptions |
MessageDataOptions |
Optional metadata to construct the message. |
signer |
Eip712Signer |
An Eip712Signer generated from the user's custody address. |
makeCastAdd
Returns a message that adds a new Cast.
Usage
Returns
| Type |
Description |
HubAsyncResult<CastAddMessage> |
A Result that contains the valid CastAddMessage |
Parameters
| Name |
Type |
Description |
body |
CastAddBody |
A valid CastAdd body object containing the data to be sent. |
dataOptions |
MessageDataOptions |
Optional metadata to construct the message. |
signer |
Ed25519Signer |
A currently valid Signer for the fid. |
makeCastRemove
Returns a message that removes an existing Cast.
Usage
Returns
| Type |
Description |
HubAsyncResult<CastRemoveMessage> |
A HubAsyncResult that contains the valid CastRemoveMessage. |
Parameters
| Name |
Type |
Description |
body |
CastRemoveBody |
A valid CastRemove body object containing the data to be sent. |
dataOptions |
MessageDataOptions |
Optional metadata to construct the message. |
signer |
Ed25519Signer |
A currently valid Signer for the fid. |
makeReactionAdd
Returns a message that adds a Reaction to an existing Cast.
Usage
Returns
| Type |
Description |
HubAsyncResult<ReactionAddMessage> |
A HubAsyncResult that contains the valid ReactionAddMessage. |
Parameters
| Name |
Type |
Description |
body |
ReactionBody |
A valid ReactionAdd body object containing the data to be sent. |
dataOptions |
MessageDataOptions |
Optional metadata to construct the message. |
signer |
Ed25519Signer |
A currently valid Signer for the fid. |
makeReactionRemove
Returns a message that removes an existing Reaction to an existing Cast.
Usage
Returns
| Type |
Description |
HubAsyncResult<ReactionRemoveMessage> |
A HubAsyncResult that contains the valid ReactionRemoveMessage. |
Parameters
| Name |
Type |
Description |
body |
ReactionBody |
A valid ReactionRemove body object containing the data to be sent. |
dataOptions |
MessageDataOptions |
Optional metadata to construct the message. |
signer |
Ed25519Signer |
A currently valid Signer for the fid. |
makeUserDataAdd
Returns a message that updates metadata about the user.
Usage
Returns
| Value |
Description |
HubAsyncResult<UserDataAddMessage> |
A HubAsyncResult that contains a signed UserDataMessage. |
Parameters
| Name |
Type |
Description |
body |
UserDataBody |
A valid UserData body object containing the data to be sent. |
dataOptions |
MessageDataOptions |
Optional metadata to construct the message. |
signer |
Ed25519Signer |
A currently valid Signer for the fid. |
makeVerificationAddEthAddress
Returns a message that proves that a user owns an Ethereum address.
Usage
Returns
| Type |
Description |
HubAsyncResult<VerificationAddEthAddressMessage> |
A HubAsyncResult that contains a signed VerificationAddEthAddressMessage. |
Parameters
| Name |
Type |
Description |
body |
VerificationAddEthAddressBody |
An object which contains an Eip712 Signature from the Ethereum Address being verified. |
dataOptions |
MessageDataOptions |
Optional metadata to construct the message. |
signer |
Ed25519Signer |
A currently valid Signer for the fid. |
makeVerificationRemove
Returns a message that removes a previously added Verification.
Usage
Returns
| Type |
Description |
HubAsyncResult<VerificationRemoveMessage> |
A HubAsyncResult that contains a signed VerificationRemoveMessage. |
Parameters
| Name |
Type |
Description |
body |
VerificationRemoveBody |
An object which contains data about the Verification being removed . |
dataOptions |
MessageDataOptions |
Optional metadata to construct the message. |
signer |
Ed25519Signer |
A currently valid Signer for the fid. |