Message Signing
Sign Typed Data
Learn how to sign a typed data object using the Okto SDK.
The signTypedData()
method generates a signature for a structured data object following the EIP712 standard. This function allows secure message signing using the OktoClient
instance.
Example
import { OktoClient } from '@okto_web3/core-js-sdk';
async function SignTypedData() {
const oktoClient = new OktoClient({
environment: process.env.OKTO_ENVIRONMENT,
clientPrivateKey: process.env.OKTO_CLIENT_PRIVATE_KEY,
clientSWA: process.env.OKTO_CLIENT_SWA,
});
const data = {
types: {
EIP712Domain: [
{ name: "name", type: "string" },
{ name: "chainId", type: "uint256" }
],
Test: [
{ name: "message", type: "string" }
]
},
primaryType: "Test",
domain: {
name: "OktoTest",
chainId: 1
},
message: {
message: "Test message"
}
};
const signedTypedData_response = await oktoClient.signTypedData(data);
console.log('Signed Typed Data: ', signedTypedData_response);
};
Note
For error handling:
- Use the error code to debug issues. Refer to the SDK errors and warnings documentation.
- For additional support, check the troubleshooting guide.
Method Overview
Method | Description |
---|---|
async signTypedData | Signs structured data using the EIP712 standard |
Sign Typed Data
async oktoClient.signTypedData(data: EIP712 Object)
generates a cryptographic signature for the structured data.
Parameters
Parameter | Type | Description | Required |
---|---|---|---|
oktoClient | OktoClient | Instance of OktoClient obtained from the useOkto hook | Yes |
data | EIP712 Object | Structured data object to be signed | Yes |
Response
Success Response
Field Name | Type | Description |
---|---|---|
result | Promise<string> | Returns the EIP712-compliant signature of the data |