waitForUserOperationTransaction
Attempts to fetch for UserOperationReceipt txMaxRetries
amount of times, at an interval of txRetryIntervalMs
milliseconds (with a multiplier of txRetryMultiplier
) using the connected account.
Note: For more details on how to modify the retry configurations for this method, see the constructor parameters.
Usage
ts
import { smartAccountClient } from "./smartAccountClient";
const userOperationResult = await smartAccountClient.sendUserOperation({
uo: {
data: "0xCalldata",
target: "0xTarget",
value: 0n,
},
});
const txHash = await smartAccountClient.waitForUserOperationTransaction({
hash: userOperationResult.hash,
});
ts
import { createMultiOwnerModularAccount } from "@alchemy/aa-accounts";
import {
LocalAccountSigner,
SmartAccountSigner,
createSmartAccountClient,
polygonMumbai,
} from "@alchemy/aa-core";
import { http } from "viem";
const chain = polygonMumbai;
const signer: SmartAccountSigner = LocalAccountSigner.mnemonicToAccountSigner(
"YOUR_OWNER_MNEMONIC"
);
const rpcTransport = http("https://polygon-mumbai.g.alchemy.com/v2/demo");
export const smartAccountClient = createSmartAccountClient({
transport: rpcTransport,
chain,
account: await createMultiOwnerModularAccount({
transport: rpcTransport,
chain,
signer,
}),
});
Returns
Promise<Hash>
A Promise
containing the hash of the transaction the user operation was included in.
If txMaxRetries
is exceeded without the user operation included in a block yet, this endpoint will throw an error. You should handle this by retrying with a higher fee and/or changing the retry configurations.
Parameters
hash: Hash
The hash of the user operation returned from sendUserOperation.