TypeScript SDK

Webhook.parse

Parses an incoming Bridge webhook payload.

function parse(
payload: string,
headers: Record<string, string>,
secret: string,
tolerance: number,
verify?: {
destinationChainId?: number;
destinationTokenAddress?: string;
minDestinationAmount?: bigint;
receiverAddress?: string;
},
): Promise<WebhookPayload>;

Parameters

The raw text body received from thirdweb.

Type

let payload: string;

The webhook headers received from thirdweb.

Type

let headers: Record<string, string>;

The webhook secret to verify the payload with.

Type

let secret: string;

The tolerance in seconds for the timestamp verification.

Type

let tolerance: number;

Add various validations to the parsed payload to ensure it matches the expected values. Throws error if any validation fails.

Type

let verify: {
destinationChainId?: number;
destinationTokenAddress?: string;
minDestinationAmount?: bigint;
receiverAddress?: string;
};

Returns

let returnType: Exclude<
z.infer<typeof webhookSchema>,
{ version: 1 }
>;