Skip to content
Starknet Start

useSignTypedData

Hook which returns the signature of an EIP712 "like" message, made by the current account of the wallet.

Usage

import {  } from "@starknetfoundation/starknet-start-react";
import { shortString } from "starknet";
 
const { ,  } = ({
  : {
    : {
      : "0x0000004f000f",
      : "0x2c94f628d125cd0e86eaefea735ba24c262b9a441728f63e5776661829a4066",
      : "400",
      : "Hector26",
      : "0x27d32a3033df4277caa9e9396100b7ca8c66a4ef8ea5f6765b91a7c17f0109c",
      : ["0x01", "0x03", "0x0a", "0x0e"],
      : "check_authorization",
      : [
        {
          : "0x69b49c2cc8b16e80e86bfc5b0614a59aa8c9b601569c7b80dde04d3f3151b79",
          : "1554785",
        },
      ],
    },
    : {
      : [
        { : "name", : "string" },
        { : "version", : "string" },
        { : "chainId", : "string" },
      ],
      : [
        { : "address", : "string" },
        { : "amount", : "string" },
      ],
      : [
        { : "id", : "string" },
        { : "from", : "string" },
        { : "amount", : "string" },
        { : "nameGamer", : "string" },
        { : "endDate", : "string" },
        { : "itemsAuthorized", : "string*" }, // array of string
        { : "chkFunction", : "selector" }, // name of function
        { : "rootList", : "merkletree", : "Airdrop" }, // root of a merkle tree
      ],
    },
    : "Validate",
    : {
      : "myDapp",
      : "1",
      : shortString.("SN_SEPOLIA"),
    },
  },
});

Arguments

params

  • Type: TypedData

TypedData. This type is defined in the Starknet Types package.

Returns

signTypedData

  • Type: (args?: TypedData) => void

Function to send the request to the user, optionally overriding the arguments to the hook.

signTypedDataAsync

  • Type: (args?: TypedData) => Promise<SIGNATURE>

Send the request to the user and block until it receives a response.

data

  • Type: SIGNATURE | undefined

The resolved data. This type is defined in the Starknet Types package.

error

  • Type: Error | null

Any error thrown by the mutation.

reset

  • Type: () => void

Reset the mutation status.

variables

  • Type: RequestArgs<"wallet_signTypedData"> | undefined

The request variables used by the underlying wallet mutation.

status

  • Type: "error" | "idle" | "pending" | "success"

The mutation status.

  • idle: the mutation has not been triggered yet.
  • pending: the mutation is being executed, e.g. waiting for the user to confirm in their wallet.
  • success: the mutation executed without an error.
  • error: the mutation threw an error.

isError

  • Type: boolean

Derived from status.

isIdle

  • Type: boolean

Derived from status.

isPending

  • Type: boolean

Derived from status.

isSuccess

  • Type: boolean

Derived from status.