Message Signing
Sign Message
Learn how to sign a message using the Okto SDK.
The signMessage()
method creates a signature for any message following the EIP191 standard. This function initiates the signing process, which can be executed using the OktoClient
instance.
Example
import { useOkto } from '@okto_web3/react-sdk';
function SignMessage() {
const oktoClient = useOkto();
const message = "Hello Okto!";
async function handleSignMessage() {
try {
const signature = await oktoClient.signMessage(message);
console.log("Signed Message: ", signature);
} catch (error) {
console.error("Error in Signing Message: ", error);
}
}
return (
<button onClick={handleSignMessage}>
Sign Message
</button>
);
}
Note
For error handling:
- Use the error code to debug issues. Check out the SDK errors and warnings documentation
- For help, navigate to the troubleshooting guide to contact support
Method Overview
Method | Description |
---|---|
async signMessage | Sign a message using EIP191 standard |
Sign Message
async oktoClient.signMessage(message: string)
creates cryptographic signature for the provided message.
Parameters
Parameter | Type | Description | Required |
---|---|---|---|
oktoClient | OktoClient | Instance of OktoClient obtained from useOkto hook | Yes |
message | String | Parameters for the Sign Message | Yes |
Response
Success Response
Field Name | Type | Description |
---|---|---|
result | Promise<string> | Returns the EIP191 compliant signature of the message |