How it works
- Create a unique reference (e.g. a random
PublicKey) - Add the reference to the instruction
- Add the reference to the
POSTresponse
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
⚠️ Dialect is sunsetting its Alerts, Blockchain Links, Markets and Positions products. If you are using these products you will need to find alternative solutions.
Track the conversion of your transactions by adding a reference key to your API
PublicKey)POST responseexport const POST = async (request: Request) => {
try {
const { account } = (await request.json()) as ActionPostRequest;
const payer = new PublicKey(account);
const ix = SystemProgram.transfer({
fromPubkey: payer,
toPubkey: new PublicKey(DONATION_DESTINATION_WALLET),
lamports: DONATION_AMOUNT_SOL * LAMPORTS_PER_SOL,
});
// Step 1: Generate random PublicKey
const reference = Keypair.generate().publicKey;
// Step 2: Add key to transaction
ix.keys.push({
pubkey: reference,
isSigner: false,
isWritable: false,
});
const transaction = await prepareTransaction([ix], payer);
// Step 3: Add to response using dialectExperimental
const response: TransactionResponse & {
dialectExperimental: { reference: string };
} = {
type: "transaction",
transaction: Buffer.from(transaction.serialize()).toString("base64"),
dialectExperimental: {
reference: reference.toString(),
},
};
return Response.json(response, { status: 200, headers });
}
};
Was this page helpful?