Skip to content

Types

Glossary of Types for Frame utilities and components

FrameButtonMetadata

type FrameButtonMetadata =
  | {
      action: 'link' | 'mint';
      label: string;
      target: string;
    }
  | {
      action?: 'post' | 'post_redirect';
      label: string;
      target?: string;
    }
  | {
      action: 'tx';
      label: string;
      target: string;
      postUrl?: string;
    };

FrameData

interface FrameData {
  buttonIndex: number;
  castId: {
    fid: number;
    hash: string;
  };
  inputText: string;
  fid: number;
  messageHash: string;
  network: number;
  state: string;
  timestamp: number;
  transactionId?: string;
  url: string;
}

FrameImageMetadata

type FrameImageMetadata = {
  src: string;
  aspectRatio?: '1.91:1' | '1:1';
};

FrameInputMetadata

type FrameInputMetadata = {
  text: string;
};

FrameMetadataResponse

type FrameMetadataResponse = Record<string, string>;

FrameMetadataReact

type FrameMetadataReact = FrameMetadataType & {
  ogDescription?: string;
  ogTitle?: string;
  wrapper?: React.ComponentType<any>;
};

FrameMetadataType

type FrameMetadataType = {
  accepts?: {
    [protocolIdentifier: string]: string;
  }; // The minimum client protocol version accepted for the given protocol identifier.
  buttons?: [FrameButtonMetadata, ...FrameButtonMetadata[]]; // A list of strings which are the label for the buttons in the frame (max 4 buttons).
  image: string | FrameImageMetadata; // An image which must be smaller than 10MB and should have an aspect ratio of 1.91:1
  input?: FrameInputMetadata; // The text input to use for the Frame.
  isOpenFrame?: boolean; // A boolean indicating if the frame uses the Open Frames standard.
  postUrl?: string; // A valid POST URL to send the Signature Packet to.
  refreshPeriod?: number; // A period in seconds at which the app should expect the image to update.
  state?: object; // A string containing serialized state (e.g. JSON) passed to the frame server.
};

FrameRequest

interface FrameRequest {
  untrustedData: FrameData;
  trustedData: {
    messageBytes: string;
  };
}

FrameValidationData

interface FrameValidationData {
  address: string | null; // The connected wallet address of the interacting user.
  button: number; // Number of the button clicked
  following: boolean; // Indicates if the viewer clicking the frame follows the cast author
  input: string; // Text input from the viewer typing in the frame
  interactor: {
    fid: number; // Viewer Farcaster ID
    custody_address: string; // Viewer custody address
    verified_accounts: string[]; // Viewer account addresses
    verified_addresses: {
      eth_addresses: string[] | null;
      sol_addresses: string[] | null;
    };
  };
  liked: boolean; // Indicates if the viewer clicking the frame liked the cast
  raw: NeynarFrameValidationInternalModel;
  recasted: boolean; // Indicates if the viewer clicking the frame recasted the cast
  state: {
    serialized: string; // Serialized state (e.g. JSON) passed to the frame server
  };
  transaction: {
    hash: string;
  } | null;
  valid: boolean; // Indicates if the frame is valid
}

FrameValidationResponse

type FrameValidationResponse =
  | { isValid: true; message: FrameValidationData }
  | { isValid: false; message: undefined };

FrameTransactionResponse

type ChainNamespace = 'eip155' | 'solana';
type ChainReference = string;
 
type FrameTransactionResponse = {
  chainId: `${ChainNamespace}:${ChainReference}`; // A CAIP-2 chain ID to identify the tx network
  method: 'eth_sendTransaction'; // A method ID to identify the type of tx request.
  params: FrameTransactionEthSendParams; // Specific parameters for chainId and method
};

FrameTransactionEthSendParams

type FrameTransactionEthSendParams = {
  abi: Abi; // The contract ABI for the contract to call.
  data?: Hex; // The data to send with the transaction.
  to: Address; // The address of the contract to call.
  value: bigint; // The amount of Ether to send with the transaction.
};