UserOp
Sign UserOp
Learn how to sign user operations using the Okto SDK.
The signUserOp()
method is available on the OktoClient instance and is used to sign user operations before they can be executed on the blockchain. This method is essential for preparing transactions in a secure manner.
Example
import { useOkto } from '@okto_web3/react-sdk';
function SignOperation() {
const oktoClient = useOkto();
// Sample UserOp before signing
const userOp = {
sender: "0xa9F6b3A5a718754979dbA78113f3614Dd4524c53",
nonce: "0x000000000000000000000000000000006c3581e0bd4f42d4a16294410c439e7a",
paymaster: "0x5408fAa7F005c46B85d82060c532b820F534437c",
callGasLimit: "0x493e0",
verificationGasLimit: "0x30d40",
preVerificationGas: "0xc350",
maxFeePerGas: "0x77359400",
maxPriorityFeePerGas: "0x77359400",
paymasterPostOpGasLimit: "0x186a0",
paymasterVerificationGasLimit: "0x186a0",
callData: "0x8dd7712f000...", // truncated for brevity
paymasterData: "0x000000000..." // truncated for brevity
};
async function handleSignOperation(userOp) {
try {
const signedOp = await oktoClient.signUserOp(userOp);
console.log('Signed operation:', signedOp);
return signedOp;
} catch (error) {
console.error('Error signing operation:', error);
}
}
return (
<button onClick={() => handleSignOperation(userOp)}>
Sign Operation
</button>
);
}
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
Method Overview
Methods | Description |
---|---|
async oktoClient.signUserOp | Sign a user operation |
Sign UserOp
async oktoClient.signUserOp(userop: UserOp)
signs a user operation with the user's credentials.
Parameters
Parameter | Type | Description | Required |
---|---|---|---|
userop | UserOp | The user operation to be signed | Yes |
Response
Success Response
Field Name | Type | Description |
---|---|---|
result | Promise<SignedUserOp> | Returns the signed user operation |