Skip to content

getFrameMessage

When a user interacts with your Frame, you receive a JSON message called the "Frame Signature Packet". Decode and validate this message using the getFrameMessage function.

Note that if the message is not valid, it will be undefined.

Usage

import { FrameRequest, getFrameMessage } from '@coinbase/onchainkit/frame'; 
import { NextRequest, NextResponse } from 'next/server';
 
async function getResponse(req: NextRequest): Promise<NextResponse> {
  const frameRequest: FrameRequest = await req.json();
  const { isValid, message } = await getFrameMessage(frameRequest); 
 
  if (isValid) {
    // the message is valid
  }
  ...
}

Returns

Promise<FrameValidationResponse>

Parameters

FrameRequest

options.neynarApiKey

  • Type: string

Default to OnchainKit's default key.

const { isValid, message } = await getFrameMessage(frameRequest, {
  neynarApiKey: 'MY_NEYNAR_API_KEY', 
});
 

options.castReactionContext

  • Type: boolean

Whether to cast the reaction context. Default: true

const { isValid, message } = await getFrameMessage(frameRequest, {
  castReactionContext: true, 
});
 

options.followContext

  • Type: boolean

Whether to follow the context. Default: true

const { isValid, message } = await getFrameMessage(frameRequest, {
  followContext: true, 
});