Skip to main content

UserWallet.signTypedData() method

Sign a typed data structure (EIP712) with the connected wallet private key

Example

// This is the message to be signed
// Now we can sign the message with the connected wallet
const { payload, signature } = await sdk.wallet.signTypedData(
{
name: "MyEIP721Domain",
version: "1",
chainId: 1,
verifyingContract: "0x...",
},
{
MyStruct: [
{ name: "to", type: "address" },
{ name: "quantity", type: "uint256" },
],
},
{ to: "0x...", quantity: 1 },
);

Signature:

signTypedData(domain: EIP712Domain, types: Record<string, Array<TypedDataField>>, message: Record<string, any>): Promise<{
payload: any;
signature: string;
}>;

Parameters

ParameterTypeDescription
domainEIP712Domainthe domain as EIP712 standard
typesRecord<string, Array<TypedDataField>>the strcuture and data types as defined by the EIP712 standard
messageRecord<string, any>the data to sign

Returns:

Promise<{ payload: any; signature: string; }>

the payload and its associated signature