Demos
Sign Message
Sign Message
This example shows how to sign a message.
Sign Message
Sign a message using the Starknet wallet
The useSignTypedData
hook
The useSignTypeData
hook implements signature in the spirit of
EIP-712.
The hook accepts 4 arguments:
types
: type definitions used inmessage
. Must contain theStarkNetDomain
type defined below.primaryType
: the root type ofmessage
.domain
: its structure must followStarkNetDomain
.message
: the message to sign and that will be displayed in the wallet.
Example data
The following snippet contains an example JSON document.
_35const exampleData = {_35 types: {_35 StarkNetDomain: [_35 { name: "name", type: "felt" },_35 { name: "version", type: "felt" },_35 { name: "chainId", type: "felt" },_35 ],_35 Person: [_35 { name: "name", type: "felt" },_35 { name: "wallet", type: "felt" },_35 ],_35 Mail: [_35 { name: "from", type: "Person" },_35 { name: "to", type: "Person" },_35 { name: "contents", type: "felt" },_35 ],_35 },_35 primaryType: "Mail",_35 domain: {_35 name: "Starknet Mail",_35 version: "1",_35 chainId: 1,_35 },_35 message: {_35 from: {_35 name: "Cow",_35 wallet: "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826",_35 },_35 to: {_35 name: "Bob",_35 wallet: "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB",_35 },_35 contents: "Hello, Bob!",_35 },_35};
This how you can use the hook to request the user to sign a piece of data.