diff --git a/.changeset/weak-moons-provide.md b/.changeset/weak-moons-provide.md new file mode 100644 index 000000000..c71be79b6 --- /dev/null +++ b/.changeset/weak-moons-provide.md @@ -0,0 +1,5 @@ +--- +"docs": patch +--- + +fix: add connectedAddress docs diff --git a/docs/pages/guides/transactions.mdx b/docs/pages/guides/transactions.mdx index 69ebdd109..db762c0d9 100644 --- a/docs/pages/guides/transactions.mdx +++ b/docs/pages/guides/transactions.mdx @@ -10,12 +10,39 @@ Frames can initiate transactions that apps that integrate Frames can complete, c An example snippet can be found below. ```tsx - // ... - buttons: [ - - ] +// ... +buttons: [ + , +]; ``` -Use the [Transactions starter](https://github.com/framesjs/frames.js/tree/main/examples/framesjs-starter/app/examples/new-api-transaction) as a template to build your transaction Frames. \ No newline at end of file +Use the [Transactions starter](https://github.com/framesjs/frames.js/tree/main/examples/framesjs-starter/app/examples/new-api-transaction) as a template to build your transaction Frames. + +## Using the connected wallet address + +The client will include the user's connected wallet address that will be executing the transaction in the frame action payload in the when a frame button with `action="tx"` set is pressed. + +The address is available in the context under the key `connectedAddress`. + +Note: + +- The address is only available when the user has connected a wallet to the client the frame button pressed is has a `tx` action. +- `connectedAddress` differs from the `requesterVerifiedAddresses` returned by the [`farcasterHubContext`](/middleware/farcasterHubContext) middleware. + +```tsx [./app/frames/tx-data/route.tsx] +import { frames } from "../frames"; + +export const POST = frames(async (ctx) => { + if (!ctx.message) { + throw new Error("No message"); + } + + const userAddress = ctx.message.connectedAddress; + + // Do something with the user's connected address that will be executing the tx + + return txData; +}); +``` diff --git a/docs/pages/reference/js/getFrameMessage.mdx b/docs/pages/reference/js/getFrameMessage.mdx index 2573e3411..3d295359f 100644 --- a/docs/pages/reference/js/getFrameMessage.mdx +++ b/docs/pages/reference/js/getFrameMessage.mdx @@ -5,7 +5,7 @@ Returns a `FrameActionData` object from the message trusted data, as well as `Fr ## Usage ```ts -import { frameMessage } from 'frames.js'; +import { getFrameMessage } from 'frames.js'; const frameMessage = await getFrameMessage(frameActionPayload); console.log(frameMessage); @@ -16,6 +16,7 @@ console.log(frameMessage); inputText: '', requesterFid: 1689, isValid: true, + connectedAddress: '0x8d25687829d6b85d9e0020b8c89e3ca24de20a89', casterFollowsRequester: false, requesterFollowsCaster: false, likedCast: false, @@ -42,7 +43,8 @@ console.log(frameMessage); buttonIndex: 2, castId: { fid: 1, hash: '0x0000000000000000000000000000000000000000' }, inputText: '', - requesterFid: 1689 + requesterFid: 1689, + connectedAddress: '0x8d25687829d6b85d9e0020b8c89e3ca24de20a89' } **/ ``` @@ -57,6 +59,8 @@ type FrameActionData = { hash: `0x${string}`; }; inputText?: string; + /** Only available in payloads of buttons with action `tx` **/ + connectedAddress: string; }; ```