Sending UserOperations
Once your UserOperation is configured, you can send it to the network. This section covers the process of sending operations and handling the results.
Sending the UserOperation
try {
// Send the UserOperation
const result = await client.sendUserOperation(builder);
// Get the transaction hash
const userOpHash = result.userOpHash;
console.log("UserOperation hash:", userOpHash);
// Wait for the transaction to be mined
const receipt = await result.wait();
console.log("Transaction hash:", receipt.transactionHash);
return receipt;
} catch (error) {
console.error("Error sending UserOperation:", error);
throw error;
}
Monitoring UserOperation Status
After sending a UserOperation, you can monitor its status:
- First, you get the
userOpHash
from the result ofsendUserOperation
. - Then, you can use
wait()
on the result to wait for the operation to be included in a block. - The receipt contains the transaction hash that can be used to look up details on a block explorer.
Next Steps
After sending UserOperations, you might want to:
- Explore advanced options for customization
- Learn about error handling for better user experience