UserOp

Sign UserOp

Learn how to sign user operations using the Okto SDK.

The signUserOp function signs a user operation for execution on the blockchain.

Example

import { useOkto } from '@okto_web3/react-native-sdk';
import { signUserOp } from '@okto_web3/react-native-sdk'; 
import { View, Text, Pressable } from 'react-native';
 
function SignOperation() {
    const oktoClient = useOkto();
 
    async function handleSign(userOp) {
        try {
            const signature = await signUserOp(oktoClient, userOp); 
            console.log('Operation signed:', signature);
        } catch (error) {
            console.error('Error signing operation:', error);
        }
    }
 
    return (
        <View>
            <Pressable onPress={handleSign}>
                <Text>Sign Operation</Text>
            </Pressable>
        </View>
    );
}

Method Overview

MethodDescription
async signUserOpSign a user operation

Sign User Operation

async signUserOp(oktoClient: OktoClient, userOp: UserOperation) signs a user operation for execution.

Parameters

ParameterTypeDescription
oktoClientOktoClientInstance of OktoClient obtained from useOkto hook
userOpUserOperationUser operation to sign

Response

Success Response

Field NameTypeDescription
signaturePromise<string>Signed user operation

Ensure the user operation is properly formatted and includes all required fields before signing.

Note

For error handling: