From e36a866f51fc3d81804df6b681f083914a0b6225 Mon Sep 17 00:00:00 2001 From: AyushBherwani1998 Date: Tue, 15 Oct 2024 07:14:27 +0530 Subject: [PATCH] improve send batch transaction --- docs/sdk/pnp/web/providers/aa-provider.mdx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/sdk/pnp/web/providers/aa-provider.mdx b/docs/sdk/pnp/web/providers/aa-provider.mdx index 386a6ec8b..86ed4f2cd 100644 --- a/docs/sdk/pnp/web/providers/aa-provider.mdx +++ b/docs/sdk/pnp/web/providers/aa-provider.mdx @@ -266,6 +266,12 @@ transaction, you'll need to use the `BundlerClient` generated by the `AccountAbs The Web3Auth instance provider can't be used for this, as it's a proxy provider designed to ensure compatibility with your preferred signer package for basic operations. +The `BundlerClient.sendUserOperation` returns the UserOperation hash instead of transaction hash. +UserOperation hash is just keccak256 hash of the entire user operation. To retreive the tranaction +details, we need to use `waitForUserOperationReceipt`. The function will wait for the UserOperation +to be included in a block, and will return a full UserOperation, with the addition of entryPoint, +blockNumber, blockHash and transactionHash. + ```ts // Use the same accountAbstractionProvider we created earlier. const bundlerClient = accountAbstractionProvider.bundlerClient!; @@ -288,6 +294,13 @@ const userOperationHash = await bundlerClient.sendUserOperation({ }, ], }); + +// Retrieve user operation receipt +const receipt = await bundlerClient.waitForUserOperationReceipt({ + hash: userOpHash, +}); + +const transactionHash = receipt.receipt.transactionHash; ``` ### Send transaction using ERC-20 Paymaster @@ -314,7 +327,7 @@ const usdcAddress = "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"; const amount = ethers.parseEther("0.00001"); -const tx = await bundlerClient.sendUserOperation({ +const userOpHash = await bundlerClient.sendUserOperation({ account: smartAccount, calls: [ // Approve USDC on Sepolia chain for Pimlico's ERC 20 Paymaster @@ -336,4 +349,11 @@ const tx = await bundlerClient.sendUserOperation({ }, ], }); + +// Retrieve user operation receipt +const receipt = await bundlerClient.waitForUserOperationReceipt({ + hash: userOpHash, +}); + +const transactionHash = receipt.receipt.transactionHash; ```