UserOp

Execute UserOp

Learn how to execute signed user operations using the Okto SDK.

The executeUserOp function submits a signed user operation to the blockchain for execution.

Example

import { useOkto } from '@okto_web3/react-native-sdk';
import { executeUserOp } from '@okto_web3/react-native-sdk'; 
import { View, Text, Pressable } from 'react-native';
 
function ExecuteOperation() {
    const oktoClient = useOkto();
 
    async function handleExecute(signedUserOp) {
        try {
            const jobId = await executeUserOp(oktoClient, signedUserOp); 
            console.log('Operation executed:', jobId);
        } catch (error) {
            console.error('Error executing operation:', error);
        }
    }
 
    return (
        <View>
            <Pressable onPress={() => {}}>
                <Text>Execute Operation</Text>
            </Pressable>
        </View>
    );
}

Method Overview

MethodDescription
async executeUserOpExecute a signed user operation

Execute User Operation

async executeUserOp(oktoClient: OktoClient, userOp: UserOperation) executes a signed user operation.

Parameters

ParameterTypeDescription
oktoClientOktoClientInstance of OktoClient obtained from useOkto hook
userOpUserOperationSigned user operation to execute

Response

Success Response

Field NameTypeDescription
resultPromise<string>Job Id of the executed operation

Ensure the user operation is properly signed before execution. Failed transactions may still consume gas.

Note

For error handling: