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-native-sdk'; 
import { TouchableOpacity, Text, View } from 'react-native';
 
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 (
        <TouchableOpacity onPress={handleSignMessage}>
            <Text>Sign Message</Text>
        </TouchableOpacity>
    );
}

Note

For error handling:

Method Overview

MethodDescription
async signMessageSign a message using EIP191 standard

Sign Message

async oktoClient.signMessage(message: string) creates cryptographic signature for the provided message.

Parameters

ParameterTypeDescriptionRequired
oktoClientOktoClientInstance of OktoClient obtained from useOkto hookYes
messageStringParameters for the Sign MessageYes

Response

Success Response

Field NameTypeDescription
resultPromise<string>Returns the EIP191 compliant signature of the message