Optional
Creates a sessions to be used when submitting batches of txs simultaneously in the context of a users smart account.
Mutation function args: UseCreateBatchSessionProps
import { useCreateBatchSession, useUserOpWait, Options } from "@biconomy/useAA"import { polygonAmoy } from "viem/chains"import { encodeFunctionData, parseAbi } from "wagmi"export const CreateBatchSession = ({userSmartAccountAddress}) => { const leafPolicy: Policy = { interval: { validUntil: 0, validAfter: 0, }, contractAddress: "0x1758f42Af7026fBbB559Dc60EcE0De3ef81f665e", functionSelector: "safeMint(address)", rules: [ { offset: 0, condition: 0, referenceValue: userSmartAccountAddress, }, ], valueLimit: 0n, } const policyLeaves: Policy[] = [leafPolicy, leafPolicy]; const { mutate, data: userOpResponse, error, isPending, } = useCreateBatchSession(); const { isLoading: waitIsLoading, isSuccess: waitIsSuccess, error: waitError, data: waitData, } = useUserOpWait(userOpResponse); const grantPermission = () => mutate({ policy: policyLeaves, options: Options.Sponsored, }); useEffect(() => { if (waitData?.success === "true") { console.log(waitData?.receipt?.transactionHash); } }, [waitData]); return ( <ErrorGuard errors={[error, waitError]}> <Button title="Grant Permission" onClickFunc={grantPermission} isLoading={isPending || waitIsLoading} /> </ErrorGuard> );}; Copy
import { useCreateBatchSession, useUserOpWait, Options } from "@biconomy/useAA"import { polygonAmoy } from "viem/chains"import { encodeFunctionData, parseAbi } from "wagmi"export const CreateBatchSession = ({userSmartAccountAddress}) => { const leafPolicy: Policy = { interval: { validUntil: 0, validAfter: 0, }, contractAddress: "0x1758f42Af7026fBbB559Dc60EcE0De3ef81f665e", functionSelector: "safeMint(address)", rules: [ { offset: 0, condition: 0, referenceValue: userSmartAccountAddress, }, ], valueLimit: 0n, } const policyLeaves: Policy[] = [leafPolicy, leafPolicy]; const { mutate, data: userOpResponse, error, isPending, } = useCreateBatchSession(); const { isLoading: waitIsLoading, isSuccess: waitIsSuccess, error: waitError, data: waitData, } = useUserOpWait(userOpResponse); const grantPermission = () => mutate({ policy: policyLeaves, options: Options.Sponsored, }); useEffect(() => { if (waitData?.success === "true") { console.log(waitData?.receipt?.transactionHash); } }, [waitData]); return ( <ErrorGuard errors={[error, waitError]}> <Button title="Grant Permission" onClickFunc={grantPermission} isLoading={isPending || waitIsLoading} /> </ErrorGuard> );};
Description
Creates a sessions to be used when submitting batches of txs simultaneously in the context of a users smart account.
Mutation function args: UseCreateBatchSessionProps
Example