diff --git a/packages/hub-web/README.md b/packages/hub-web/README.md index 60de8e17e4..78add0b01b 100644 --- a/packages/hub-web/README.md +++ b/packages/hub-web/README.md @@ -40,6 +40,27 @@ try { } ``` +### Get the username by FID + +```typescript +const getFnameFromFid = async ( + fid: number, + client: HubRpcClient +): HubAsyncResult => { + const result = await client.getUserData({ + fid: fid, + userDataType: UserDataType.FNAME, + }); + return result.map((message) => { + if (isUserDataAddMessage(message)) { + return message.data.userDataBody.value; + } else { + return ''; + } + }); +}; +``` + ### Running the examples There are several examples in the `examples/` folder. To run the examples, please look at the individual README files in the examples directory. Most examples can be run by