Setting up Your Headers

At this point, we need to construct the headers object that will be targeted by our Action. There are two kinds of headers we need:

  1. the CORS (cross-origin resource sharing) headers;

The first is required because all Action endpoints must handle HTTP OPTIONS requests with appropriate headers, thus ensuring clients can successfully pass CORS checks for all subsequent requests from the same origin domain.

The second is required because different Blink clients, such as wallets, update at different rates. This means they might not support the latest features, which can lead to situations where the Blink is rendered incorrectly, e.g., with elements being invisible, displayed incorrectly, or being completely non-functional.

The Action spec version and chain headers allow you to specify the spec version the Action API server is using.

If the spec version and chain are not explicitly included here, it will default to the latest pre-compatibility version and a Solana Mainnet-Beta Action.

const headers = createActionHeaders({
  chainId: "mainnet", // or chainId: "devnet"
  actionVersion: "2.2.1", // the desired spec version
});

For more context and detail, check out the linked documentation. Continue on to the next section, in which we'll talk about the GET and OPTIONS headers.

Last updated