-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
123 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
# OnchainKit | ||
|
||
<p align="left"> | ||
OnchainKit is a collection of lightweight, composable, and type-safe React components along with TypeScript utilities to create top-tier onchain applications. | ||
OnchainKit: React components and TypeScript utilities for top-tier onchain apps. | ||
<p> | ||
|
||
<p align="left"> | ||
|
@@ -40,6 +40,10 @@ | |
</a> | ||
</p> | ||
|
||
## Documentation | ||
|
||
For documentation and guides, visit [onchainkit.xyz](https://onchainkit.xyz/). | ||
|
||
## Getting Started | ||
|
||
Add OnchainKit to your project, install the required packages. | ||
|
@@ -59,8 +63,11 @@ pnpm add @coinbase/onchainkit [email protected] react@18 react-dom@18 | |
|
||
OnchainKit is divided into various theme utilities and components that are available for your use: | ||
|
||
- [Frame Kit 🖼️](https://github.com/coinbase/onchainkit?tab=readme-ov-file#frame-kit-%EF%B8%8F) | ||
- [Identity Kit 👨🚀](https://github.com/coinbase/onchainkit?tab=readme-ov-file#identity-kit-) | ||
- [Farcaster Kit](https://onchainkit.xyz/farcasterkit/introduction) | ||
- Utilitis: | ||
- [`getFarcasterUserAddress`](https://onchainkit.xyz/farcasterkit/get-farcaster-user-address) | ||
- [Frame Kit](https://github.com/coinbase/onchainkit?tab=readme-ov-file#frame-kit-%EF%B8%8F) | ||
- [Identity Kit](https://github.com/coinbase/onchainkit?tab=readme-ov-file#identity-kit-) | ||
|
||
<br /> | ||
<br /> | ||
|
Binary file not shown.
66 changes: 66 additions & 0 deletions
66
site/docs/pages/farcasterkit/get-farcaster-user-address.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# getFarcasterUserAddress | ||
|
||
The `getFarcasterUserAddress` function retrieves the user address associated | ||
with a given Farcaster ID (fid). It provides options to specify whether | ||
the client wants **custody address** and/or **verified addresses**, | ||
and also allows the user to provide their own neynar api key. | ||
|
||
By default, both **custody** and **verified** addresses are provided. | ||
|
||
## Usage | ||
|
||
```ts | ||
import { getFarcasterUserAddress } from '@coinbase/onchainkit/farcaster'; | ||
|
||
const userAddress = await getFarcasterUserAddress(fid, options); // [!code focus] | ||
``` | ||
|
||
## Returns | ||
|
||
[`GetFarcasterUserAddressResponse`](/farcasterkit/types#getfarcasteruseraddressresponse) | ||
|
||
Returns the Custody Address and the list of all verified addresses of a given fid. | ||
|
||
## Parameters | ||
|
||
### fid | ||
|
||
- **Type:** `string` | ||
|
||
Farcaster ID | ||
|
||
### options.neynarApiKey | ||
|
||
- **Type:** `string` | ||
|
||
Default to onchain-kit's default key. | ||
|
||
```ts | ||
const userAddress = await getFarcasterUserAddress(fid, { | ||
neynarApiKey: 'MY_NEYNAR_API_KEY', // [!code focus] | ||
}); | ||
``` | ||
|
||
### options.hasCustodyAddress | ||
|
||
- **Type:** `boolean` | ||
|
||
Optional options to specify if the client wants custody addresses. Default to true. | ||
|
||
```ts | ||
const userAddress = await getFarcasterUserAddress(fid, { | ||
hasCustodyAddress: false, // [!code focus] | ||
}); | ||
``` | ||
|
||
### options.hasVerifiedAddresses | ||
|
||
- **Type:** `boolean` | ||
|
||
Optional options to specify if the client wants verified addresses. Default to true. | ||
|
||
```ts | ||
const userAddress = await getFarcasterUserAddress(fid, { | ||
hasVerifiedAddresses: false, // [!code focus] | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,21 @@ | ||
### getFarcasterUserAddress | ||
# Introduction to Farcaster Kit [A brief introduction on essential Farcaster knowledge.] | ||
|
||
The `getFarcasterUserAddress` function retrieves the user address associated with a given Farcaster ID (fid). It provides options to specify whether the client wants `custody address` and/or `verified addresses`, and also allows the user to provide their own neynar api key. By default, both `custody` and `verified` addresses are provided. | ||
Farcaster is a decentralized social network on Ethereum. | ||
Users create profiles, post "casts," and follow others. | ||
They own their [accounts](https://docs.farcaster.xyz/learn/what-is-farcaster/accounts) and relationships. | ||
|
||
```tsx | ||
import { getFarcasterUserAddress } from '@coinbase/onchainkit/farcaster'; | ||
To join, users need an Ethereum address for onchain registration. | ||
|
||
async function fetchUserAddress(fid: number) { | ||
// Returns custody and verified addresses. If there is an error, returns null | ||
const userAddress = await getFarcasterUserAddress(fid); | ||
console.log(userAddress); | ||
} | ||
Farcaster [contracts](https://docs.farcaster.xyz/learn/architecture/contracts) are deployed on Optimism, an Ethereum Layer 2 network. | ||
Core contracts include ID Registry, Key Registry, and Storage Registry. | ||
|
||
fetchUserAddress(3); | ||
``` | ||
[ID Registry](https://docs.farcaster.xyz/reference/contracts/reference/id-registry) tracks Farcaster IDs (aka FID), linking them to Ethereum addresses. [Key Registry](https://docs.farcaster.xyz/reference/contracts/reference/key-gateway) links Farcaster IDs with ed25519 public keys. | ||
|
||
**@Param** | ||
Only [messages](https://docs.farcaster.xyz/learn/what-is-farcaster/messages) signed by registered keys are valid. | ||
|
||
```ts | ||
// Fid - Farcaster Id | ||
fid: number; | ||
To assist you in engaging with Farcaster, here is the Farcaster Kit which includes: | ||
|
||
// Optional options to specify whether the client wants custody and/or verified addresses | ||
// along with their neynar api key | ||
type GetFarcasterUserAddressOptions = | ||
| { | ||
neynarApiKey?: string; // default to onchain-kit's default key | ||
hasCustodyAddress?: boolean; // default to true | ||
hasVerifiedAddresses?: boolean; // default to true | ||
} | ||
| undefined; | ||
``` | ||
|
||
**@Returns** | ||
|
||
```ts | ||
type GetFarcasterUserAddressResponse = { | ||
// Custody Address of a given fid | ||
custodyAddress?: string; | ||
// List of all verified addresses for a given fid | ||
verifiedAddresses?: string[]; | ||
}; | ||
``` | ||
- Utilities: | ||
- [getFarcasterUserAddress](/farcasterkit/get-farcaster-user-address) | ||
- Types: | ||
- [GetFarcasterUserAddressResponse]() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Types [Glossary of Types in Farcaster Kit.] | ||
|
||
## `GetFarcasterUserAddressResponse` | ||
|
||
```ts | ||
type GetFarcasterUserAddressResponse = { | ||
custodyAddress?: string; // Custody Address of a given fid | ||
verifiedAddresses?: string[]; // List of all verified addresses for a given fid | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const version = '0.6.1'; | ||
export const version = '0.6.2'; |