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
Method | Description |
---|---|
async executeUserOp | Execute a signed user operation |
Execute User Operation
async executeUserOp(oktoClient: OktoClient, userOp: UserOperation)
executes a signed user operation.
Parameters
Parameter | Type | Description |
---|---|---|
oktoClient | OktoClient | Instance of OktoClient obtained from useOkto hook |
userOp | UserOperation | Signed user operation to execute |
Response
Success Response
Field Name | Type | Description |
---|---|---|
result | Promise<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:
- 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