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
Method | Description |
---|---|
async signUserOp | Sign a user operation |
Sign User Operation
async signUserOp(oktoClient: OktoClient, userOp: UserOperation)
signs a user operation for execution.
Parameters
Parameter | Type | Description |
---|---|---|
oktoClient | OktoClient | Instance of OktoClient obtained from useOkto hook |
userOp | UserOperation | User operation to sign |
Response
Success Response
Field Name | Type | Description |
---|---|---|
signature | Promise<string> | Signed user operation |
Ensure the user operation is properly formatted and includes all required fields before signing.
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