verifyMessage
Action for verifying a signed Starknet message.
Import
import { verifyMessage } from "starkweb/core";
Usage
index.ts
import { verifyMessage } from "starkweb/core";
import { config } from "./config";
const isValid = await verifyMessage(config, {
message: "Hello Starknet!",
signature: ["0x123...", "0x456..."],
publicKey: "0x789...",
});
Parameters
import { type VerifyMessageParameters } from "starkweb/core";
message
string
The original message that was signed.
signature
Hex[]
The signature components to verify.
publicKey
Hex
The public key to verify against.
index.ts
import { verifyMessage } from "starkweb/core";
import { config } from "./config";
const isValid = await verifyMessage(config, {
message: "Hello Starknet!",
signature: ["0x123...", "0x456..."],
publicKey: "0x789...",
});
chainId (optional)
Hex | undefined
The chain ID to verify on. If not provided, uses the current chain.
index.ts
import { verifyMessage } from "starkweb/core";
import { mainnet } from "starkweb/chains";
import { config } from "./config";
const isValid = await verifyMessage(config, {
message: "Hello Starknet!",
signature: ["0x123...", "0x456..."],
publicKey: "0x789...",
chainId: mainnet.chain_id,
});
Return Type
import { type VerifyMessageReturnType } from "starkweb/core";
boolean
Whether the signature is valid.
Example
example.ts
import { verifyMessage } from "starkweb/core";
import { mainnet } from "starkweb/chains";
import { config } from "./config";
// Verify on current chain
const isValid = await verifyMessage(config, {
message: "Hello Starknet!",
signature: ["0x123...", "0x456..."],
publicKey: "0x789...",
});
console.log("Is signature valid?", isValid);
// Verify on specific chain
const isValidOnMainnet = await verifyMessage(config, {
message: "Hello Starknet!",
signature: ["0x123...", "0x456..."],
publicKey: "0x789...",
chainId: mainnet.chain_id,
});
Error
import { type VerifyMessageErrorType } from "starkweb/core";