Structuring the GET and OPTIONS Request

Now, let's discuss how GET and OPTIONS requests work.

The metadata of an Action is returned when a payload is used to submit a GET request to the Action API endpoint. For the complete scope of the payload, check out the GET Request specifications.

Once that's done, the payload and associated CORS headers are sent in the GET response.

Here's the basic structure of the GET request with the payload:

export const GET = async (req: Request) => {
  const payload: ActionGetResponse = {
    title: "Actions Example - Simple On-chain Memo",
    icon: 'https://ucarecdn.com/7aa46c85-08a4-4bc7-9376-88ec48bb1f43/-/preview/880x864/-/quality/smart/-/format/auto/',
    description: "Send a message on-chain using a Memo",
    label: "Send Memo",
  };

  return Response.json(payload, {
    headers,
  });
}

This example is a simple Action for sending a memo transaction to a predefined wallet address. It contains the bare minimum metadata that can be returned by an Action's GET request.

This marks the end of the basic 'setup' procedures. In the next section we'll begin our discussion of some of the amazing things you can do with Actions.

Last updated