signMessage
Action for signing a message with a Starknet account.
Import
import { signMessage } from "starkweb/core";
Usage
index.ts
import { signMessage } from "starkweb/core";
import { config } from "./config";
const signature = await signMessage(config, {
message: "Hello Starknet!",
});
Parameters
import { type SignMessageParameters } from "starkweb/core";
message
string
The message to sign.
index.ts
import { signMessage } from "starkweb/core";
import { config } from "./config";
const signature = await signMessage(config, {
message: "Hello Starknet!",
});
connector (optional)
Connector | undefined
The connector to use for signing. If not provided, uses the current connector.
index.ts
import { signMessage } from "starkweb/core";
import { injected } from "starkweb/connectors";
import { config } from "./config";
const connector = injected();
const signature = await signMessage(config, {
message: "Hello Starknet!",
connector,
});
Return Type
import { type SignMessageReturnType } from "starkweb/core";
Hex[]
Array of signature components.
Example
example.ts
import { signMessage } from "starkweb/core";
import { injected } from "starkweb/connectors";
import { config } from "./config";
// Sign with current connector
const signature = await signMessage(config, {
message: "Hello Starknet!",
});
console.log("Signature:", signature);
// Sign with specific connector
const connector = injected();
const injectedSignature = await signMessage(config, {
message: "Hello Starknet!",
connector,
});
Error
import { type SignMessageErrorType } from "starkweb/core";
TanStack Query
import {
type SignMessageData,
type SignMessageMutate,
type SignMessageMutateAsync,
type SignMessageVariables,
signMessageMutationOptions,
} from "starkweb/query";