verifySignature

Verifies the signature based on the provided options. Handles smart contract wallet signatures and EOA signatures. IMPORTANT: in order to check smart contract signatures, a chain and client must be provided. Or, you can use the verifyContractWalletSignature function directly if all signatures will be from smart accounts.

Example

import { verifySignature } from "thirdweb/auth";
const isValid = await verifySignature({
message: "Your message to sign",
signature:
"0x91db0222ec371a8c18d3b187a6d2e77789bffca1b96826ef6b8708e0d4a66c80312fc3ae95b8fbc147265abf539bb6f360152be61a0e1411d7f5771a599e769a1c",
address: "0xda9C7A86AeE76701FC1c23ae548e8E93Ba3e42A5",
client: thirdwebClient,
chain: chain,
});
function verifySignature(options: {
accountFactory?: {
address: string;
verificationCalldata: `0x${string}`;
};
address: string;
chain?: Readonly<ChainOptions & { rpc: string }>;
client?: ThirdwebClient;
message: string;
signature: (string | Uint8Array<ArrayBufferLike> | Signature) &
(string | Uint8Array<ArrayBufferLike> | Signature | undefined);
}): Promise<boolean>;

Parameters

The options for signature verification.

Type

let options: {
accountFactory?: {
address: string;
verificationCalldata: `0x${string}`;
};
address: string;
chain?: Readonly<ChainOptions & { rpc: string }>;
client?: ThirdwebClient;
message: string;
signature: (string | Uint8Array<ArrayBufferLike> | Signature) &
(string | Uint8Array<ArrayBufferLike> | Signature | undefined);
};

Returns

let returnType: Promise<boolean>;

A boolean indicating whether the signature is valid or not.