Skip to content

Commit

Permalink
Merge pull request #944 from Web3Auth/aa-provider
Browse files Browse the repository at this point in the history
  • Loading branch information
yashovardhan authored Oct 15, 2024
2 parents 0a1c801 + e36a866 commit 79a0818
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion docs/sdk/pnp/web/providers/aa-provider.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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!;
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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;
```

0 comments on commit 79a0818

Please sign in to comment.