This is an open sourced Hono server deployed via a Cloudflare worker that can be used for creating and authorizing signer keys on Farcaster. It's not the most ideal approach as something like Farcaster Auth is much more streamline and scales better, but it can come in handy for certain use cases and educational settings on how keys in Farcaster work.
It is currently being used in production to assist with authorizing Raycaster.
Clone the repo then install the packages with your manager of choice (i.e. bun install
)
Then create a file called .dev.vars
and put the following values in:
FARCASTER_DEVELOPER_FID= # The FID of the app account (e.g. @raycasterapp) that will be signing the keys
FARCASTER_DEVELOPER_MNEMONIC= # The mnemonic phrase for the same app account
After setting the environment variables start up the server
bun run dev
Creates a keypair, sign it, then make a signed-key-request
to Warpcast. If successful it will return the following data.
{
"deepLinkUrl": "farcaster://signed-key-request?token=<POLLING_TOKEN>",
"pollingToken": "<POLLING_TOKEN>",
"privateKey": "<PRIVATE_KEY>",
"publicKey": "<PUBLIC_KEY>"
}
deepLinkUrl
- Can be turned into a QR code or button on mobile to open up Warpcast to approve the signed keypollingToken
- Used in the/sign-in/poll
edpoint to check on the status of whether the key has been approvedprivateKey
&publicKey
- The signed keypair
Checks the status of an approval for an existing signed keypair, uses a query parameter of ?token=TOKEN
like so:
/sign-in/poll?token=<pollingToken>
Returns the following data:
{
"state": "approved",
"userFid": 6023
}
state
- Can either bepending
orapproved
userFid
- Once a key is approved it will also return the user FID that approved the key
Returns a QR code that can be scanned by a mobile deviced based on the pollingToken
passed into the path parameter.
If you have any questions at all feel free to contact me!