diff --git a/packages/accounts/src/index.ts b/packages/accounts/src/index.ts index ba67e6ef1e..082458ebf3 100644 --- a/packages/accounts/src/index.ts +++ b/packages/accounts/src/index.ts @@ -5,6 +5,7 @@ export type * from "./light-account/account.js"; export { createLightAccount } from "./light-account/account.js"; export { transferOwnership as transferLightAccountOwnership } from "./light-account/actions/transferOwnership.js"; +export { createLightAccountClient } from "./light-account/createLightAccountClient.js"; export { getLightAccountVersion } from "./light-account/getLightAccountVersion.js"; export type * from "./light-account/lightAccountClientDecorator.js"; export { lightAccountClientActions } from "./light-account/lightAccountClientDecorator.js"; diff --git a/packages/core/src/client/bundlerClient.ts b/packages/core/src/client/bundlerClient.ts index 799b62ce47..ebe5afe16d 100644 --- a/packages/core/src/client/bundlerClient.ts +++ b/packages/core/src/client/bundlerClient.ts @@ -42,14 +42,20 @@ export const createBundlerClientFromExisting: < * @returns */ export function createBundlerClient( - args: PublicClientConfig + args: PublicClientConfig & { type?: string } ): BundlerClient; -export function createBundlerClient(args: PublicClientConfig): BundlerClient { +export function createBundlerClient( + args: PublicClientConfig & { type?: string } +): BundlerClient { if (!args.chain) { throw new Error("Chain must be provided"); } - const { key = "bundler-public", name = "Public Bundler Client" } = args; + const { + key = "bundler-public", + name = "Public Bundler Client", + type = "bundlerClient", + } = args; const { transport, ...opts } = args; const resolvedTransport = transport({ @@ -61,7 +67,7 @@ export function createBundlerClient(args: PublicClientConfig): BundlerClient { ...args, key, name, - type: "bundlerClient", + type, }; const client = (() => { diff --git a/packages/core/src/client/smartAccountClient.ts b/packages/core/src/client/smartAccountClient.ts index 1b324eeb2b..e4a94ff534 100644 --- a/packages/core/src/client/smartAccountClient.ts +++ b/packages/core/src/client/smartAccountClient.ts @@ -1,7 +1,5 @@ import { - createClient, custom, - publicActions, type Chain, type Client, type ClientConfig, @@ -16,9 +14,8 @@ import type { SmartContractAccount } from "../account/smartContractAccount.js"; import { middlewareActions } from "../middleware/actions.js"; import type { ClientMiddleware } from "../middleware/types.js"; import type { Prettify } from "../utils/index.js"; -import type { BundlerClient } from "./bundlerClient.js"; +import { createBundlerClient, type BundlerClient } from "./bundlerClient.js"; import { - bundlerActions, type BundlerActions, type BundlerRpcSchema, } from "./decorators/bundlerClient.js"; @@ -111,7 +108,7 @@ export function createSmartAccountClient( ...params } = config; - const client = createClient({ + const client = createBundlerClient({ ...params, key, name, @@ -125,8 +122,6 @@ export function createSmartAccountClient( .extend(() => ({ ...SmartAccountClientOptsSchema.parse(config.opts ?? {}), })) - .extend(publicActions) - .extend(bundlerActions) .extend(middlewareActions(config)) .extend(smartAccountClientActions); } diff --git a/site/overview/faqs.md b/site/overview/faqs.md index 337a4bf81e..791e8830c7 100644 --- a/site/overview/faqs.md +++ b/site/overview/faqs.md @@ -64,9 +64,9 @@ If the `UserOperation` (meta-transaction for 4337 accounts) is correctly priced ::: details Answer This can happen when `UserOperation`s (UOs) become underpriced, frequently due to fee market movement between when gas and fees are estimations and when the UO is actually submitted. -You may experience this when calling the [`waitForUserOperationTransaction`](/packages/aa-core/smart-account-client/waitForUserOperationTransaction.html#waitForUserOperationTransaction) method. It may throw an error if it does not find the UO in a mined Transaction within its retry limits. +You may experience this when calling the [`waitForUserOperationTransaction`](/packages/aa-core/smart-account-client/actions/waitForUserOperationTransaction.html#waitForUserOperationTransaction) method. It may throw an error if it does not find the UO in a mined Transaction within its retry limits. -You can mitigate this by defining a more flexible retry period when constructing a [`Provider`](/packages/aa-core/smart-account-client/createSmartAccountClient.html#constructor) (i.e. `txMaxRetries`, `txRetryIntervalMs`, `txRetryMultiplier` in `opts`). If your UO continues to be delayed beyond a limit you are willing to wait, you can resubmit it using [`dropAndReplaceUserOperation`](/packages/aa-core/smart-account-client/dropAndReplaceUserOperation.html#dropandreplaceuseroperation). +You can mitigate this by defining a more flexible retry period when constructing a [`Client`](/packages/aa-core/smart-account-client/index.html#usage) (i.e. `txMaxRetries`, `txRetryIntervalMs`, `txRetryMultiplier` in `opts`). If your UO continues to be delayed beyond a limit you are willing to wait, you can resubmit it using [`dropAndReplaceUserOperation`](/packages/aa-core/smart-account-client/actions/dropAndReplaceUserOperation.html#dropandreplaceuseroperation). ::: ### Are `UserOperation`s protected from MEV bots? @@ -156,9 +156,9 @@ Currently our Bundler allows max 10M gas in aggregate between `preVerificationGa ### `waitForUserOperationTransaction` timeout ::: details Answer -[`waitForUserOperationTransaction`](/packages/aa-core/smart-account-client/waitForUserOperationTransaction) may throw this error if it does not find the mined User Operation within its retry limits. +[`waitForUserOperationTransaction`](/packages/aa-core/smart-account-client/actions/waitForUserOperationTransaction) may throw this error if it does not find the mined User Operation within its retry limits. -You can mitigate this by defining a more flexible retry period when constructing a [`Client`](/packages/aa-core/smart-account-client/createSmartAccountClient.html#usage) (i.e. `txMaxRetries`, `txRetryIntervalMs`, `txRetryMultiplier` in `opts`). +You can mitigate this by defining a more flexible retry period when constructing a [`Client`](/packages/aa-core/smart-account-client/index.html#usage) (i.e. `txMaxRetries`, `txRetryIntervalMs`, `txRetryMultiplier` in `opts`). -If your `UserOperation` continues to be delayed beyond a limit you are willing to wait, you can resubmit the user operation using [`dropAndReplaceUserOperation`](/packages/aa-core/smart-account-client/dropAndReplaceUserOperation.html#dropandreplaceuseroperation). +If your `UserOperation` continues to be delayed beyond a limit you are willing to wait, you can resubmit the user operation using [`dropAndReplaceUserOperation`](/packages/aa-core/smart-account-client/actions/dropAndReplaceUserOperation.html#usage). ::: diff --git a/site/packages/aa-accounts/light-account/encodeTransferOwnership.md b/site/packages/aa-accounts/light-account/encodeTransferOwnership.md index 3b144904d1..952ac457ff 100644 --- a/site/packages/aa-accounts/light-account/encodeTransferOwnership.md +++ b/site/packages/aa-accounts/light-account/encodeTransferOwnership.md @@ -29,7 +29,7 @@ const encodedTransferOwnershipData = LightSmartContractAccount.encodeTransferOwnership(newOwner); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: ## Returns diff --git a/site/packages/aa-accounts/light-account/getOwnerAddress.md b/site/packages/aa-accounts/light-account/getOwnerAddress.md index 3e1f28e239..1dfc2cfb1c 100644 --- a/site/packages/aa-accounts/light-account/getOwnerAddress.md +++ b/site/packages/aa-accounts/light-account/getOwnerAddress.md @@ -27,7 +27,7 @@ import { provider } from "./provider"; const owner = await provider.account.getOwnerAddress(); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: ## Returns diff --git a/site/packages/aa-accounts/light-account/introduction.md b/site/packages/aa-accounts/light-account/introduction.md index 7d326166c6..4e9dc0707d 100644 --- a/site/packages/aa-accounts/light-account/introduction.md +++ b/site/packages/aa-accounts/light-account/introduction.md @@ -65,7 +65,7 @@ const result = await LightSmartContractAccount.transferOwnership( ); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: ## Developer Links diff --git a/site/packages/aa-accounts/light-account/signMessageWith6492.md b/site/packages/aa-accounts/light-account/signMessageWith6492.md index f0396ee911..063c4d5aab 100644 --- a/site/packages/aa-accounts/light-account/signMessageWith6492.md +++ b/site/packages/aa-accounts/light-account/signMessageWith6492.md @@ -27,7 +27,7 @@ import { provider } from "./provider"; const signedMessageWith6492 = provider.signMessageWith6492("test"); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: ## Returns diff --git a/site/packages/aa-accounts/light-account/signTypedData.md b/site/packages/aa-accounts/light-account/signTypedData.md index 1cf07a9903..a213cab605 100644 --- a/site/packages/aa-accounts/light-account/signTypedData.md +++ b/site/packages/aa-accounts/light-account/signTypedData.md @@ -57,7 +57,7 @@ const signedTypedData = provider.signTypedData({ }); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: ## Returns diff --git a/site/packages/aa-accounts/light-account/signTypedDataWith6492.md b/site/packages/aa-accounts/light-account/signTypedDataWith6492.md index 71ad269a0b..140a3b36b9 100644 --- a/site/packages/aa-accounts/light-account/signTypedDataWith6492.md +++ b/site/packages/aa-accounts/light-account/signTypedDataWith6492.md @@ -57,7 +57,7 @@ const signedTypedDataWith6492 = provider.signTypedDataWith6492({ }); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: ## Returns diff --git a/site/packages/aa-accounts/light-account/transferOwnership.md b/site/packages/aa-accounts/light-account/transferOwnership.md index a49193d168..414ae7693e 100644 --- a/site/packages/aa-accounts/light-account/transferOwnership.md +++ b/site/packages/aa-accounts/light-account/transferOwnership.md @@ -34,7 +34,7 @@ const result = await LightSmartContractAccount.transferOwnership( ); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: ## Returns diff --git a/site/packages/aa-alchemy/index.md b/site/packages/aa-alchemy/index.md index 0d79fd21e8..3fe06cc820 100644 --- a/site/packages/aa-alchemy/index.md +++ b/site/packages/aa-alchemy/index.md @@ -44,6 +44,6 @@ pnpm i @alchemy/aa-alchemy Then, you can create a provider like so: ::: code-group -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/packages/aa-alchemy/middleware/introduction.md b/site/packages/aa-alchemy/middleware/introduction.md index 77391f507a..119ec78ace 100644 --- a/site/packages/aa-alchemy/middleware/introduction.md +++ b/site/packages/aa-alchemy/middleware/introduction.md @@ -50,5 +50,5 @@ const providerWithGasManager = withAlchemyGasManager( ); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/packages/aa-alchemy/middleware/withAlchemyGasFeeEstimator.md b/site/packages/aa-alchemy/middleware/withAlchemyGasFeeEstimator.md index 43455da592..e07d7584c1 100644 --- a/site/packages/aa-alchemy/middleware/withAlchemyGasFeeEstimator.md +++ b/site/packages/aa-alchemy/middleware/withAlchemyGasFeeEstimator.md @@ -33,7 +33,7 @@ const providerWithGasFeeEstimator = withAlchemyGasFeeEstimator( ); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: ## Returns diff --git a/site/packages/aa-alchemy/middleware/withAlchemyGasManager.md b/site/packages/aa-alchemy/middleware/withAlchemyGasManager.md index c1cd3a5d59..37f6594fbb 100644 --- a/site/packages/aa-alchemy/middleware/withAlchemyGasManager.md +++ b/site/packages/aa-alchemy/middleware/withAlchemyGasManager.md @@ -34,7 +34,7 @@ const providerWithGasManager = withAlchemyGasManager( ); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: ## Returns diff --git a/site/packages/aa-alchemy/middleware/withAlchemyUserOpSimulation.md b/site/packages/aa-alchemy/middleware/withAlchemyUserOpSimulation.md index 0a63f79ee8..c4400b95fc 100644 --- a/site/packages/aa-alchemy/middleware/withAlchemyUserOpSimulation.md +++ b/site/packages/aa-alchemy/middleware/withAlchemyUserOpSimulation.md @@ -30,7 +30,7 @@ import { withAlchemyUserOpSimulation } from "@alchemy/aa-alchemy"; const providerWithUserOpSimulation = withAlchemyUserOpSimulation(provider); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: ## Returns diff --git a/site/packages/aa-alchemy/provider/gasEstimator.md b/site/packages/aa-alchemy/provider/gasEstimator.md index f9d8cc0ac6..52e6135c29 100644 --- a/site/packages/aa-alchemy/provider/gasEstimator.md +++ b/site/packages/aa-alchemy/provider/gasEstimator.md @@ -32,7 +32,7 @@ const uoStruct = await provider.buildUserOperation({ const uoHash = await provider.sendUserOperation(uoStruct); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: ## Returns @@ -45,4 +45,4 @@ the resulting user operation struct after gas estimation, run as part of a middl ### `struct: Deferrable` -- the struct containing UserOperation fields, where each field may be asychronously returned from the middleware used to generate its final value. -Note: You typically will call this method as part of a middleware chain when building and sending UserOperations, so the parameters of `UserOperationStruct` should be generated for you, as long as you pass in the initial parameters needed for [sendUserOperation](/packages/aa-core/smart-account-client/sendUserOperation). +Note: You typically will call this method as part of a middleware chain when building and sending UserOperations, so the parameters of `UserOperationStruct` should be generated for you, as long as you pass in the initial parameters needed for [sendUserOperation](/packages/aa-core/smart-account-client/actions/sendUserOperation). diff --git a/site/packages/aa-alchemy/provider/introduction.md b/site/packages/aa-alchemy/provider/introduction.md index 1169a10f09..1ac248bd75 100644 --- a/site/packages/aa-alchemy/provider/introduction.md +++ b/site/packages/aa-alchemy/provider/introduction.md @@ -14,11 +14,10 @@ head: # AlchemyProvider -`AlchemyProvider` is an extension of the [`SmartAccountProvider`](/packages/aa-core/smart-account-client/introduction) implementation. It's a simpler interface you can use to leverage the Alchemy stack - JSON-RPC requests via API Key or JSON Web Token (JWT), Rundler (an [EIP-4337](https://eips.ethereum.org/EIPS/eip-4337) Bundler), and Gas Manager (an [EIP-4337](https://eips.ethereum.org/EIPS/eip-4337) Paymaster). +`AlchemyProvider` is an extension of the [`SmartAccountProvider`](/packages/aa-core/smart-account-client/index) implementation. It's a simpler interface you can use to leverage the Alchemy stack - JSON-RPC requests via API Key or JSON Web Token (JWT), Rundler (an [EIP-4337](https://eips.ethereum.org/EIPS/eip-4337) Bundler), and Gas Manager (an [EIP-4337](https://eips.ethereum.org/EIPS/eip-4337) Paymaster). Notable differences between `AlchemyProvider` and `SmartAccountProvider` are implementations for: -1. [`gasEstimator`](/packages/aa-core/smart-account-client/withGasEstimator.md) -- overrides the base `SmartAccountProvider` gas estimator. 2. [`withAlchemyGasManager`](/packages/aa-alchemy/provider/withAlchemyGasManager.md) -- adds the Alchemy Gas Manager middleware to the provider. ## Usage @@ -42,5 +41,5 @@ const providerWithGasManager = provider.withAlchemyGasManager({ }); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/packages/aa-alchemy/provider/simulateUserOperationAssetChanges.md b/site/packages/aa-alchemy/provider/simulateUserOperationAssetChanges.md index 32eec1b92a..40c752315a 100644 --- a/site/packages/aa-alchemy/provider/simulateUserOperationAssetChanges.md +++ b/site/packages/aa-alchemy/provider/simulateUserOperationAssetChanges.md @@ -39,7 +39,7 @@ if (uoSimResult.error) { const uo = await provider.sendUserOperation(uoStruct); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: ## Returns diff --git a/site/packages/aa-alchemy/provider/withAlchemyEnhancedApis.md b/site/packages/aa-alchemy/provider/withAlchemyEnhancedApis.md index 0f9f67d01c..b1f0903b24 100644 --- a/site/packages/aa-alchemy/provider/withAlchemyEnhancedApis.md +++ b/site/packages/aa-alchemy/provider/withAlchemyEnhancedApis.md @@ -40,7 +40,7 @@ const alchemy = new Alchemy(); const providerWithEnhancedApis = provider.withAlchemyEnhancedApis(alchemy); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: ## Returns diff --git a/site/packages/aa-alchemy/provider/withAlchemyGasManager.md b/site/packages/aa-alchemy/provider/withAlchemyGasManager.md index c4790115d9..b323cd922b 100644 --- a/site/packages/aa-alchemy/provider/withAlchemyGasManager.md +++ b/site/packages/aa-alchemy/provider/withAlchemyGasManager.md @@ -30,7 +30,7 @@ const providerWithGasManager = provider.withAlchemyGasManager({ }); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: ## Returns diff --git a/site/packages/aa-alchemy/provider/withAlchemyUserOpSimulation.md b/site/packages/aa-alchemy/provider/withAlchemyUserOpSimulation.md index a6d929213a..b138da92c1 100644 --- a/site/packages/aa-alchemy/provider/withAlchemyUserOpSimulation.md +++ b/site/packages/aa-alchemy/provider/withAlchemyUserOpSimulation.md @@ -28,7 +28,7 @@ import { provider } from "./provider"; const providerWithGasManager = provider.withAlchemyUserOpSimulation(); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: ## Returns diff --git a/site/packages/aa-core/accounts/introduction.md b/site/packages/aa-core/accounts/introduction.md index 61c2d496a2..2424b62f08 100644 --- a/site/packages/aa-core/accounts/introduction.md +++ b/site/packages/aa-core/accounts/introduction.md @@ -24,7 +24,7 @@ prev: ## BaseSmartContractAccount -The `BaseSmartContractAccount` is an abstract class that provides the base implementation the `ISmartContractAccount` interface to provide the ease of creating your own Smart Contract Account. Any class that extends and implements `BaseSmartContractAccount` may also expose additional methods that support its connecting [SmartAccountProvider](/packages/aa-core/smart-account-client/introduction). +The `BaseSmartContractAccount` is an abstract class that provides the base implementation the `ISmartContractAccount` interface to provide the ease of creating your own Smart Contract Account. Any class that extends and implements `BaseSmartContractAccount` may also expose additional methods that support its connecting [SmartAccountProvider](/packages/aa-core/smart-account-client/index). `BaseSmartContractAccount` contains abstract methods that requires implementation from any class that extends the class. diff --git a/site/packages/aa-core/accounts/optional/signMessageWith6492.md b/site/packages/aa-core/accounts/optional/signMessageWith6492.md index 5018014d3e..17e8111819 100644 --- a/site/packages/aa-core/accounts/optional/signMessageWith6492.md +++ b/site/packages/aa-core/accounts/optional/signMessageWith6492.md @@ -23,12 +23,12 @@ This method wraps the result of `signMessage` as per [EIP-6492](https://eips.eth ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] const signedMsgWrappedWith6492 = await provider.signMessageWith6492("msg"); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/packages/aa-core/accounts/optional/signTypedData.md b/site/packages/aa-core/accounts/optional/signTypedData.md index 324f4207dd..adff6f16f1 100644 --- a/site/packages/aa-core/accounts/optional/signTypedData.md +++ b/site/packages/aa-core/accounts/optional/signTypedData.md @@ -21,7 +21,7 @@ If your contract supports signing and verifying typed data, you should implement ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] // sign typed data const signedTypedData = provider.signTypedData({ @@ -57,7 +57,7 @@ const signedTypedData = provider.signTypedData({ }); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/packages/aa-core/accounts/optional/signTypedDataWith6492.md b/site/packages/aa-core/accounts/optional/signTypedDataWith6492.md index 42125d344a..702372bf54 100644 --- a/site/packages/aa-core/accounts/optional/signTypedDataWith6492.md +++ b/site/packages/aa-core/accounts/optional/signTypedDataWith6492.md @@ -23,7 +23,7 @@ Similar to the signMessageWith6492 method above, this method wraps the result of ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] const signedTypedDataWrappedWith6492 = provider.signTypedDataWith6492({ domain: { @@ -58,7 +58,7 @@ const signedTypedDataWrappedWith6492 = provider.signTypedDataWith6492({ }); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/packages/aa-core/accounts/optional/signUserOperationHash.md b/site/packages/aa-core/accounts/optional/signUserOperationHash.md index e3898cf228..422d63b272 100644 --- a/site/packages/aa-core/accounts/optional/signUserOperationHash.md +++ b/site/packages/aa-core/accounts/optional/signUserOperationHash.md @@ -25,14 +25,14 @@ If your account handles [ERC-1271 signatures](https://eips.ethereum.org/EIPS/eip ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] const signature = await provider.account.signUserOperationHash( `` ); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/packages/aa-core/accounts/other/getAddress.md b/site/packages/aa-core/accounts/other/getAddress.md index 720c6b84ed..f1285e0f87 100644 --- a/site/packages/aa-core/accounts/other/getAddress.md +++ b/site/packages/aa-core/accounts/other/getAddress.md @@ -21,12 +21,12 @@ Returns the address of the account. ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] const address = await provider.account.getAddress(); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/packages/aa-core/accounts/other/getDeploymentState.md b/site/packages/aa-core/accounts/other/getDeploymentState.md index 1b582b8840..4678a5d7de 100644 --- a/site/packages/aa-core/accounts/other/getDeploymentState.md +++ b/site/packages/aa-core/accounts/other/getDeploymentState.md @@ -21,12 +21,12 @@ Returns the current deployment state as an enum `DeploymentState` (`UNDEFINED`, ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] const deploymentState = await provider.account.getDeploymentState(); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/packages/aa-core/accounts/other/getEntryPointAddress.md b/site/packages/aa-core/accounts/other/getEntryPointAddress.md index 0f34bbdc17..f0122fd5cf 100644 --- a/site/packages/aa-core/accounts/other/getEntryPointAddress.md +++ b/site/packages/aa-core/accounts/other/getEntryPointAddress.md @@ -25,12 +25,12 @@ Refer to [the reference docs](https://docs.alchemy.com/reference/eth-supporteden ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] const entryPointAddress = await provider.account.getEntryPointAddress(); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/packages/aa-core/accounts/other/getFactoryAddress.md b/site/packages/aa-core/accounts/other/getFactoryAddress.md index 7f561f052b..08804beb22 100644 --- a/site/packages/aa-core/accounts/other/getFactoryAddress.md +++ b/site/packages/aa-core/accounts/other/getFactoryAddress.md @@ -21,12 +21,12 @@ Returns the account factory address for the account. ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] const factoryAddress = await provider.account.getFactoryAddress(); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/packages/aa-core/accounts/other/getNonce.md b/site/packages/aa-core/accounts/other/getNonce.md index c781a336bf..dc3e7cb2b0 100644 --- a/site/packages/aa-core/accounts/other/getNonce.md +++ b/site/packages/aa-core/accounts/other/getNonce.md @@ -21,12 +21,12 @@ Returns the nonce of the account. ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] const address = await provider.account.getNonce(); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/packages/aa-core/accounts/other/getOwner.md b/site/packages/aa-core/accounts/other/getOwner.md index 58dcfa433c..45a4e4f890 100644 --- a/site/packages/aa-core/accounts/other/getOwner.md +++ b/site/packages/aa-core/accounts/other/getOwner.md @@ -21,12 +21,12 @@ Returns the `SmartAccountSigner` that represents the current owner for the accou ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] const ownerSigner = await provider.account.getOwner(); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/packages/aa-core/accounts/other/isAccountDeployed.md b/site/packages/aa-core/accounts/other/isAccountDeployed.md index 1b0ad98894..92f8c17bc5 100644 --- a/site/packages/aa-core/accounts/other/isAccountDeployed.md +++ b/site/packages/aa-core/accounts/other/isAccountDeployed.md @@ -21,12 +21,12 @@ Returns a boolean flag indicating whether the account has been deployed or not. ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] const isAccountDeployed = await provider.account.isAccountDeployed(); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/packages/aa-core/accounts/required/getAccountInitCode.md b/site/packages/aa-core/accounts/required/getAccountInitCode.md index cad40e81e7..ee01aacb50 100644 --- a/site/packages/aa-core/accounts/required/getAccountInitCode.md +++ b/site/packages/aa-core/accounts/required/getAccountInitCode.md @@ -48,14 +48,14 @@ async getAccountInitCode(): Promise<`0x${string}`> { ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] const initCode = await provider.getAccountInitCode(); const factoryAddress = `0x${initCode.substring(2, 42)}` as Address; const factoryCalldata = `0x${initCode.substring(42)}` as Hex; ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/packages/aa-core/accounts/required/getDummySignature.md b/site/packages/aa-core/accounts/required/getDummySignature.md index a4fbf4eef0..fed4a33bde 100644 --- a/site/packages/aa-core/accounts/required/getDummySignature.md +++ b/site/packages/aa-core/accounts/required/getDummySignature.md @@ -41,12 +41,12 @@ getDummySignature(): `0x${string}` { ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] const dummySignature = await provider.getDummySignature(); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/packages/aa-core/accounts/required/signMessage.md b/site/packages/aa-core/accounts/required/signMessage.md index 3ae8d72cd8..a1a073eead 100644 --- a/site/packages/aa-core/accounts/required/signMessage.md +++ b/site/packages/aa-core/accounts/required/signMessage.md @@ -21,12 +21,12 @@ This method should return an [ERC-191](https://eips.ethereum.org/EIPS/eip-191) c ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] const signedMessage = await provider.signMessage("msg"); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/packages/aa-core/smart-account-client/actions/buildUserOperation.md b/site/packages/aa-core/smart-account-client/actions/buildUserOperation.md index 17850e067f..4201ca0c24 100644 --- a/site/packages/aa-core/smart-account-client/actions/buildUserOperation.md +++ b/site/packages/aa-core/smart-account-client/actions/buildUserOperation.md @@ -31,34 +31,40 @@ Note that `to` field of transaction is required, and among other fields of trans ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] // build single -const uoStruct = await provider.buildUserOperation({ - target: TO_ADDRESS, - data: ENCODED_DATA, - value: VALUE, // optional +const uoStruct = await smartAccountClient.buildUserOperation({ + uo: { + target: TO_ADDRESS, + data: ENCODED_DATA, + value: VALUE, // optional + }, +}); +const { hash: uoHash } = await smartAccountClient.sendUserOperation({ + uo: uoStruct, }); -const { hash: uoHash } = await provider.sendUserOperation(uoStruct); // build batch -const batchedUoStruct = await provider.buildUserOperation([ - { - data: "0xCalldata", - target: "0xTarget", - }, - { - data: "0xCalldata2", - target: "0xTarget2", - value: 1000n, // in wei - }, -]); -const { hash: batchedUoHash } = await provider.sendUserOperation( - batchedUoStruct -); +const batchedUoStruct = await smartAccountClient.buildUserOperation({ + uo: [ + { + data: "0xCalldata", + target: "0xTarget", + }, + { + data: "0xCalldata2", + target: "0xTarget2", + value: 1000n, // in wei + }, + ], +}); +const { hash: batchedUoHash } = await smartAccountClient.sendUserOperation({ + uo: batchedUoStruct, +}); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: ## Returns @@ -69,7 +75,7 @@ A Promise containing the _unsigned_ UO struct resulting from the middleware pipe ## Parameters -### `UserOperationCallData | UserOperationCallData[]` +### `uo: UserOperationCallData | UserOperationCallData[]` - `target: Address` - the target of the call (equivalent to `to` in a transaction) - `data: Hex` - can be either `0x` or a call data string @@ -78,3 +84,7 @@ A Promise containing the _unsigned_ UO struct resulting from the middleware pipe ### `overrides?:` [`UserOperationOverrides`](/packages/aa-core/smart-account-client/types/userOperationOverrides.md) Optional parameter where you can specify override values for `maxFeePerGas`, `maxPriorityFeePerGas`, `callGasLimit`, `preVerificationGas`, `verificationGasLimit` or `paymasterAndData` on the user operation request + +### `account?: SmartContractAccount` + +If your client was not instantiated with an account, then you will have to pass the account in to this call. diff --git a/site/packages/aa-core/smart-account-client/actions/buildUserOperationFromTx.md b/site/packages/aa-core/smart-account-client/actions/buildUserOperationFromTx.md index b6293372cc..f924638334 100644 --- a/site/packages/aa-core/smart-account-client/actions/buildUserOperationFromTx.md +++ b/site/packages/aa-core/smart-account-client/actions/buildUserOperationFromTx.md @@ -31,9 +31,9 @@ Note that `to` field of transaction is required, and among other fields of trans ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] -const uoStruct = await provider.buildUserOperationFromTx({ +const uoStruct = await smartAccountClient.buildUserOperationFromTx({ from, // ignored to, data: encodeFunctionData({ @@ -42,10 +42,10 @@ const uoStruct = await provider.buildUserOperationFromTx({ args: [arg1, arg2, ...], }), }); -const uoHash = await provider.sendUserOperation(uoStruct); +const uoHash = await smartAccountClient.sendUserOperation(uoStruct); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: ## Returns @@ -63,3 +63,7 @@ The `RpcTransactionRequest` object representing a traditional ethereum transacti ### `overrides?:` [`UserOperationOverrides`](/packages/aa-core/smart-account-client/types/userOperationOverrides.md) Optional parameter where you can specify override values for `maxFeePerGas`, `maxPriorityFeePerGas`, `callGasLimit`, `preVerificationGas`, `verificationGasLimit` or `paymasterAndData` on the user operation request + +### `account?: SmartContractAccount` + +If your client was not instantiated with an account, then you will have to pass the account in to this call. diff --git a/site/packages/aa-core/smart-account-client/actions/checkGasSponsorshipEligibility.md b/site/packages/aa-core/smart-account-client/actions/checkGasSponsorshipEligibility.md index 4c02b176c4..d93d7cccbf 100644 --- a/site/packages/aa-core/smart-account-client/actions/checkGasSponsorshipEligibility.md +++ b/site/packages/aa-core/smart-account-client/actions/checkGasSponsorshipEligibility.md @@ -27,9 +27,9 @@ For a deeper understanding of how to employ this method to provide varied user e ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] -const eligible = await provider.checkGasSponsorshipEligibility({ +const eligible = await smartAccountClient.checkGasSponsorshipEligibility({ data: "0xCalldata", target: "0xTarget", value: 0n, @@ -42,7 +42,7 @@ console.log( ); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: ## Returns @@ -62,3 +62,7 @@ A Promise containing the boolean value indicating whether the UO to be sent is e ### `overrides?:` [`UserOperationOverrides`](/packages/aa-core/smart-account-client/types/userOperationOverrides.md) Optional parameter where you can specify override values for `maxFeePerGas`, `maxPriorityFeePerGas`, `callGasLimit`, `preVerificationGas`, `verificationGasLimit` or `paymasterAndData` on the user operation request + +### `account?: SmartContractAccount` + +If your client was not instantiated with an account, then you will have to pass the account in to this call. diff --git a/site/packages/aa-core/smart-account-client/actions/dropAndReplaceUserOperation.md b/site/packages/aa-core/smart-account-client/actions/dropAndReplaceUserOperation.md index 1c74fcbcbd..c62d2ac469 100644 --- a/site/packages/aa-core/smart-account-client/actions/dropAndReplaceUserOperation.md +++ b/site/packages/aa-core/smart-account-client/actions/dropAndReplaceUserOperation.md @@ -21,20 +21,21 @@ Attempts to drop and replace an existing user operation by increasing fees. The ::: code-group ```ts [example.ts] -import { provider } from "./provider"; - -const { request } = await provider.sendUserOperation({ - data: "0xCalldata", - target: "0xTarget", - value: 0n, +import { smartAccountClient } from "./smartAccountClient"; + +const { request } = await smartAccountClient.sendUserOperation({ + uo: { + data: "0xCalldata", + target: "0xTarget", + value: 0n, + }, }); -const { hash: replacedHash } = await provider.dropAndReplaceUserOperation( - request -); +const { hash: replacedHash } = + await smartAccountClient.dropAndReplaceUserOperation(request); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: ## Returns @@ -54,3 +55,7 @@ A previously submitted `UserOperation`. ### `overrides?:` [`UserOperationOverrides`](/packages/aa-core/smart-account-client/types/userOperationOverrides.md) Optional parameter where you can specify override values for `maxFeePerGas`, `maxPriorityFeePerGas`, `callGasLimit`, `preVerificationGas`, `verificationGasLimit` or `paymasterAndData` on the user operation request + +### `account?: SmartContractAccount` + +If your client was not instantiated with an account, then you will have to pass the account in to this call. diff --git a/site/packages/aa-core/smart-account-client/actions/getAddress.md b/site/packages/aa-core/smart-account-client/actions/getAddress.md index c5d8cf1796..0c6cc42cf5 100644 --- a/site/packages/aa-core/smart-account-client/actions/getAddress.md +++ b/site/packages/aa-core/smart-account-client/actions/getAddress.md @@ -21,12 +21,12 @@ Returns the address of the connected account. Throws error if there is no connec ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] -const address = await provider.getAddress(); +const address = await smartAccountClient.getAddress(); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: @@ -35,3 +35,9 @@ const address = await provider.getAddress(); ### `Promise
` A Promise that resolves to the address of the connected account + +## Parameters + +### `account?: SmartContractAccount` + +If your client was not instantiated with an account, then you will have to pass the account in to this call. diff --git a/site/packages/aa-core/smart-account-client/actions/getEntryPointAddress.md b/site/packages/aa-core/smart-account-client/actions/getEntryPointAddress.md deleted file mode 100644 index da755a7a42..0000000000 --- a/site/packages/aa-core/smart-account-client/actions/getEntryPointAddress.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -outline: deep -head: - - - meta - - property: og:title - content: getEntryPointAddress - - - meta - - name: description - content: Overview of the getEntryPointAddress method on ISmartAccountProvider - - - meta - - property: og:description - content: Overview of the getEntryPointAddress method on ISmartAccountProvider ---- - -# getEntryPointAddress - -Returns the EntryPoint contract address being used for the provider. - -If the provider is connected with a `SmartContractAccount`, the EntryPoint contract of the connected account is used for the provider. - -If not connected, it fallbacks to the default entry point contract for the chain, unless the optional parameter `entryPointAddress` was given during the initialization as an override. - -Refer to [the reference docs](https://docs.alchemy.com/reference/eth-supportedentrypoints/?a=ak-docs) for all the supported entrypoints when using Alchemy as your RPC provider. - -## Usage - -::: code-group - -```ts [example.ts] -import { provider } from "./provider"; -// [!code focus:99] -const entryPointAddress = await provider.getEntryPointAddress(); -``` - -<<< @/snippets/provider.ts - -::: - -## Returns - -### `Address` - -The address of the EntryPoint contract diff --git a/site/packages/aa-core/smart-account-client/actions/getUserOperationByHash.md b/site/packages/aa-core/smart-account-client/actions/getUserOperationByHash.md index fd9dc91daa..aae62a49a5 100644 --- a/site/packages/aa-core/smart-account-client/actions/getUserOperationByHash.md +++ b/site/packages/aa-core/smart-account-client/actions/getUserOperationByHash.md @@ -21,12 +21,12 @@ Return a `UserOperation` (UO) based on a hash (userOpHash). ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] -provider.getUserOperationByHash("0xUserOpResultHash"); +smartAccountClient.getUserOperationByHash({ hash: "0xUserOpResultHash" }); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/packages/aa-core/smart-account-client/actions/getUserOperationReceipt.md b/site/packages/aa-core/smart-account-client/actions/getUserOperationReceipt.md index 259ae1f0c7..e9a92967eb 100644 --- a/site/packages/aa-core/smart-account-client/actions/getUserOperationReceipt.md +++ b/site/packages/aa-core/smart-account-client/actions/getUserOperationReceipt.md @@ -21,12 +21,12 @@ Return a UserOperationReceipt based on a hash (userOpHash). ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] -provider.getUserOperationReceipt("0xUserOpResultHash"); +smartAccountClient.getUserOperationReceipt({ hash: "0xUserOpResultHash" }); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/packages/aa-core/smart-account-client/actions/request.md b/site/packages/aa-core/smart-account-client/actions/request.md index 41096d7d53..25e34d65d0 100644 --- a/site/packages/aa-core/smart-account-client/actions/request.md +++ b/site/packages/aa-core/smart-account-client/actions/request.md @@ -21,25 +21,25 @@ head: ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] -const result = await provider.request({ +const result = await smartAccountClient.request({ method: "eth_sendTransaction", params: [tx], }); -const result = await provider.request({ +const result = await smartAccountClient.request({ method: "eth_sign", params: [address, data], }); -const result = await provider.request({ +const result = await smartAccountClient.request({ method: "eth_signTypedData_v4", params: [address, dataParams], }); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/packages/aa-core/smart-account-client/actions/sendTransaction.md b/site/packages/aa-core/smart-account-client/actions/sendTransaction.md index c8a426a25c..93eeb288cb 100644 --- a/site/packages/aa-core/smart-account-client/actions/sendTransaction.md +++ b/site/packages/aa-core/smart-account-client/actions/sendTransaction.md @@ -25,9 +25,9 @@ Note that `to` field of transaction is required, and among other fields of trans ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] -const txHash = await provider.sendTransaction({ +const txHash = await smartAccountClient.sendTransaction({ from, // ignored to, data: encodeFunctionData({ @@ -38,7 +38,7 @@ const txHash = await provider.sendTransaction({ }); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: @@ -50,10 +50,14 @@ A Promise containing the transaction hash ## Parameters -### `request: RpcTransactionRequest` +### `...request: RpcTransactionRequest` The `RpcTransactionRequest` object representing a traditional ethereum transaction ### `overrides?:` [`UserOperationOverrides`](/packages/aa-core/smart-account-client/types/userOperationOverrides.md) Optional parameter where you can specify override values for `maxFeePerGas`, `maxPriorityFeePerGas`, `callGasLimit`, `preVerificationGas`, `verificationGasLimit` or `paymasterAndData` on the user operation request + +### `account?: SmartContractAccount` + +If your client was not instantiated with an account, then you will have to pass the account in to this call. diff --git a/site/packages/aa-core/smart-account-client/actions/sendTransactions.md b/site/packages/aa-core/smart-account-client/actions/sendTransactions.md index 02f8562eb3..5fb9fce4db 100644 --- a/site/packages/aa-core/smart-account-client/actions/sendTransactions.md +++ b/site/packages/aa-core/smart-account-client/actions/sendTransactions.md @@ -25,9 +25,9 @@ Also note that `to` field of transaction is required, and among other fields of ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] -const txHash = await provider.sendTransactions([ +const txHash = await smartAccountClient.sendTransactions({requests: [ { from, // ignored to, @@ -56,10 +56,10 @@ const txHash = await provider.sendTransactions([ args: [arg1, arg2, ...], }), }, -]); +]}); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: @@ -71,10 +71,14 @@ A Promise containing the transaction hash ## Parameters -### `request: RpcTransactionRequest[]` +### `requests: RpcTransactionRequest[]` An `RpcTransactionRequest` array representing a traditional ethereum transaction ### `overrides?:` [`UserOperationOverrides`](/packages/aa-core/smart-account-client/types/userOperationOverrides.md) Optional parameter where you can specify override values for `maxFeePerGas`, `maxPriorityFeePerGas`, `callGasLimit`, `preVerificationGas`, `verificationGasLimit` or `paymasterAndData` on the user operation request + +### `account?: SmartContractAccount` + +If your client was not instantiated with an account, then you will have to pass the account in to this call. diff --git a/site/packages/aa-core/smart-account-client/actions/sendUserOperation.md b/site/packages/aa-core/smart-account-client/actions/sendUserOperation.md index 1b3a0cc071..83b1873c9a 100644 --- a/site/packages/aa-core/smart-account-client/actions/sendUserOperation.md +++ b/site/packages/aa-core/smart-account-client/actions/sendUserOperation.md @@ -29,30 +29,34 @@ Before executing, sendUserOperation will run the user operation through the midd ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] // send single -provider.sendUserOperation({ - data: "0xCalldata", - target: "0xTarget", - value: 0n, -}); - -// send batch -provider.sendUserOperation([ - { +smartAccountClient.sendUserOperation({ + uo: { data: "0xCalldata", target: "0xTarget", + value: 0n, }, - { - data: "0xCalldata2", - target: "0xTarget2", - value: 1000n, // in wei - }, -]); +}); + +// send batch +smartAccountClient.sendUserOperation({ + uo: [ + { + data: "0xCalldata", + target: "0xTarget", + }, + { + data: "0xCalldata2", + target: "0xTarget2", + value: 1000n, // in wei + }, + ], +}); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: ## Returns @@ -76,3 +80,7 @@ A Promise containing the hash of the user operation and the request that was sen ### `overrides?:` [`UserOperationOverrides`](/packages/aa-core/smart-account-client/types/userOperationOverrides.md) Optional parameter where you can specify override values for `maxFeePerGas`, `maxPriorityFeePerGas`, `callGasLimit`, `preVerificationGas`, `verificationGasLimit` or `paymasterAndData` on the user operation request + +### `account?: SmartContractAccount` + +If your client was not instantiated with an account, then you will have to pass the account in to this call. diff --git a/site/packages/aa-core/smart-account-client/actions/signMessage.md b/site/packages/aa-core/smart-account-client/actions/signMessage.md index eb07407223..03b5cbd254 100644 --- a/site/packages/aa-core/smart-account-client/actions/signMessage.md +++ b/site/packages/aa-core/smart-account-client/actions/signMessage.md @@ -21,12 +21,12 @@ This method signs messages using the connected account with [ERC-191](https://ei ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] -const signedMessage = await provider.signMessage("msg"); +const signedMessage = await smartAccountClient.signMessage({ message: "msg" }); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: @@ -38,6 +38,10 @@ The signed hash for the message passed ## Parameters -### `msg: string | Uint8Array` +### `message: SignableMessage` -Message to be signed +Message to be signed represented as a viem [`SignableMessage`](https://viem.sh/docs/actions/wallet/signMessage.html#signmessage) + +### `account?: SmartContractAccount` + +If your client was not instantiated with an account, then you will have to pass the account in to this call. diff --git a/site/packages/aa-core/smart-account-client/actions/signMessageWith6492.md b/site/packages/aa-core/smart-account-client/actions/signMessageWith6492.md index 99d11eaffe..6566ac17e1 100644 --- a/site/packages/aa-core/smart-account-client/actions/signMessageWith6492.md +++ b/site/packages/aa-core/smart-account-client/actions/signMessageWith6492.md @@ -21,13 +21,15 @@ This method supports signing messages for deployed smart accounts, as well as un ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] // sign message (works for undeployed and deployed accounts) -const signedMessageWith6492 = provider.signMessageWith6492("test"); +const signedMessageWith6492 = smartAccountClient.signMessageWith6492({ + message: "test", +}); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: @@ -42,3 +44,7 @@ A Promise containing the signature of the message, additionally wrapped in EIP-6 ### `msg: string | Uint8Array` The message to sign + +### `account?: SmartContractAccount` + +If your client was not instantiated with an account, then you will have to pass the account in to this call. diff --git a/site/packages/aa-core/smart-account-client/actions/signTypedData.md b/site/packages/aa-core/smart-account-client/actions/signTypedData.md index 6751ebd990..0dea19254c 100644 --- a/site/packages/aa-core/smart-account-client/actions/signTypedData.md +++ b/site/packages/aa-core/smart-account-client/actions/signTypedData.md @@ -21,10 +21,10 @@ This method signs sign typed data using the connected account with [ERC-712](htt ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] // sign typed data -const signedTypedData = provider.signTypedData({ +const signedTypedData = smartAccountClient.signTypedData({ domain: { name: "Ether Mail", version: "1", @@ -57,7 +57,7 @@ const signedTypedData = provider.signTypedData({ }); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: @@ -75,3 +75,7 @@ A Promise containing the signature of the typed data - `types: Object` -- the type definitions for the typed data - `primaryType: inferred String` -- the primary type to extract from types and use in value - `message: inferred from types & primaryType` -- the message, inferred from + +### `account?: SmartContractAccount` + +If your client was not instantiated with an account, then you will have to pass the account in to this call. diff --git a/site/packages/aa-core/smart-account-client/actions/signTypedDataWith6492.md b/site/packages/aa-core/smart-account-client/actions/signTypedDataWith6492.md index b97b4d8c87..1c0f33dd56 100644 --- a/site/packages/aa-core/smart-account-client/actions/signTypedDataWith6492.md +++ b/site/packages/aa-core/smart-account-client/actions/signTypedDataWith6492.md @@ -21,10 +21,10 @@ This method supports signing typed data for deployed smart accounts, as well as ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./smartAccountClient"; // [!code focus:99] // sign typed data (works for undeployed and deployed accounts) -const signedTypedDataWith6492 = provider.signTypedDataWith6492({ +const signedTypedDataWith6492 = smartAccountClient.signTypedDataWith6492({ domain: { name: "Ether Mail", version: "1", @@ -57,7 +57,7 @@ const signedTypedDataWith6492 = provider.signTypedDataWith6492({ }); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: @@ -77,3 +77,7 @@ The typed data to sign - `types: Object` -- the type definitions for the typed data - `primaryType: inferred String` -- the primary type to extract from types and use in value - `message: inferred from types & primaryType` -- the message, inferred from + +### `account?: SmartContractAccount` + +If your client was not instantiated with an account, then you will have to pass the account in to this call. diff --git a/site/packages/aa-core/smart-account-client/actions/waitForUserOperationTransaction.md b/site/packages/aa-core/smart-account-client/actions/waitForUserOperationTransaction.md index 9c5cbc0914..cfcc514b97 100644 --- a/site/packages/aa-core/smart-account-client/actions/waitForUserOperationTransaction.md +++ b/site/packages/aa-core/smart-account-client/actions/waitForUserOperationTransaction.md @@ -16,28 +16,30 @@ head: Attempts to fetch for UserOperationReceipt `txMaxRetries` amount of times, at an interval of `txRetryIntervalMs` milliseconds (with a multiplier of `txRetryMulitplier`) using the connected account. -Note: For more details on how to modify the retry configurations for this method, see the [constructor](/packages/aa-core/smart-account-client/createSmartAccountClient.md) parameters. +Note: For more details on how to modify the retry configurations for this method, see the [constructor](/packages/aa-core/smart-account-client/index.md) parameters. ## Usage ::: code-group ```ts [example.ts] -import { provider } from "./provider"; +import { smartAccountClient } from "./provider"; // [!code focus:99] -const userOperationResult = await provider.sendUserOperation({ - data: "0xCalldata", - target: "0xTarget", - value: 0n, +const userOperationResult = await smartAccountClient.sendUserOperation({ + uo: { + data: "0xCalldata", + target: "0xTarget", + value: 0n, + }, }); // [!code focus:99] -const txHash = await provider.waitForUserOperationTransaction({ +const txHash = await smartAccountClient.waitForUserOperationTransaction({ hash: userOperationResult.hash, }); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: ## Returns diff --git a/site/packages/aa-core/smart-account-client/types/userOperationFeeOptions.md b/site/packages/aa-core/smart-account-client/types/userOperationFeeOptions.md index 6759f03dc4..4b67bb6541 100644 --- a/site/packages/aa-core/smart-account-client/types/userOperationFeeOptions.md +++ b/site/packages/aa-core/smart-account-client/types/userOperationFeeOptions.md @@ -14,7 +14,7 @@ head: # UserOperationFeeOptions -Fee options object type used by the [`SmartAccountProvider`](/packages/aa-core/smart-account-client/createSmartAccountClient.md) during the gas fee calculation middlewares when constructing the user operation to send. +Fee options object type used by the [`SmartAccountProvider`](/packages/aa-core/smart-account-client/index.md) during the gas fee calculation middlewares when constructing the user operation to send. For example, if the below example `UserOperationFeeOptions` is set on the provider upon initialization, the `maxPriorityFeePerGas` field on the user operation will be set as the max value between the 50% buffered `maxPriorityFeePerGas` estimate and the the min `maxPriorityFeePerGas` value specified here, `100_000_000n`. diff --git a/site/packages/aa-core/smart-account-client/types/userOperationFeeOptionsField.md b/site/packages/aa-core/smart-account-client/types/userOperationFeeOptionsField.md index 205a62ea77..56c2c33d40 100644 --- a/site/packages/aa-core/smart-account-client/types/userOperationFeeOptionsField.md +++ b/site/packages/aa-core/smart-account-client/types/userOperationFeeOptionsField.md @@ -14,9 +14,9 @@ head: # UserOperationFeeOptionsField -Merged type of [`BigNumberishRange`](/glossary/types.md#bignumberishrange) with [`Percentage`](/glossary/types.md#percentage) type that can be used as [`UserOperationFeeOptions`](./userOperationFeeOptions.md) fields for the [`SmartAccountProvider`](/packages/aa-core/smart-account-client/createSmartAccountClient.md) to use during the gas fee calculation middlewares when constructing the user operation to send. +Merged type of [`BigNumberishRange`](/glossary/types.md#bignumberishrange) with [`Percentage`](/glossary/types.md#percentage) type that can be used as [`UserOperationFeeOptions`](./userOperationFeeOptions.md) fields for the [`SmartAccountProvider`](/packages/aa-core/smart-account-client/index.md) to use during the gas fee calculation middlewares when constructing the user operation to send. -For example, if the below example `UserOperationFeeOptionsField` is set as the fee option for the `maxPriorityFeePerGas` field of [`UserOperationFeeOptions`](./userOperationFeeOptions.md), then the [`SmartAccountProvider`](/packages/aa-core/smart-account-client/createSmartAccountClient.md) will apply 50% buffer to the estimated `maxPriorityFeePerGas`, then set the `maxPriorityFeePerGas` on the user operation as the larger value between the buffered `maxPriorityFeePerGas` fee and the min `maxPriorityFeePerGas` which is `100_000_000n` here. +For example, if the below example `UserOperationFeeOptionsField` is set as the fee option for the `maxPriorityFeePerGas` field of [`UserOperationFeeOptions`](./userOperationFeeOptions.md), then the [`SmartAccountProvider`](/packages/aa-core/smart-account-client/index.md) will apply 50% buffer to the estimated `maxPriorityFeePerGas`, then set the `maxPriorityFeePerGas` on the user operation as the larger value between the buffered `maxPriorityFeePerGas` fee and the min `maxPriorityFeePerGas` which is `100_000_000n` here. ```ts /* diff --git a/site/packages/aa-core/smart-account-client/types/userOperationOverrides.md b/site/packages/aa-core/smart-account-client/types/userOperationOverrides.md index f30abbdc3e..8aa64a6cee 100644 --- a/site/packages/aa-core/smart-account-client/types/userOperationOverrides.md +++ b/site/packages/aa-core/smart-account-client/types/userOperationOverrides.md @@ -18,14 +18,14 @@ next: Contains override values to be applied on the user operation reqeust to be constructed or sent. Available fields include `maxFeePerGas`, `maxPriorityFeePerGas`, `callGasLimit`, `preVerificationGas`, `verificationGasLimit` or `paymasterAndData`. -These override values are available from each middleware of the `SmartAccountProvider`. For example, the default middlewares such as [`gasEstimator`](/packages/aa-core/smart-account-client/withGasEstimator.md) or [`feeDataGetter`](/packages/aa-core/smart-account-client/withFeeDataGetter.md) apply the overrides values to the estimated values if the override values are provided. +These override values are available from each middleware of the `SmartAccountProvider`. For example, the default middlewares such as `gasEstimator` or `feeEstimator` apply the overrides values to the estimated values if the override values are provided. Other than the `paymasterAndData` field, the override fields could be either the absolute value or the percentage value. In the default middlewares, if the override value is an absolute value, it simply overrides the estimated value. If the override value is a percentage value, the estimated value is _bumped_ with the indicated percentage value. For example, if the override value is `{ percentage: 10 }` for the `maxPriorityFeePerGas` field, then 10% bump is applied to the estimated `maxPriorityFeePerGas` of the user operation. The `paymasterAndData` only allows an absolute value override, and if the override value is provided, then the paymaster middleware is bypassed entirely. Refer to our guide [How to Handle User Operations that are Not Eligible for Gas Sponsorship](/tutorials/sponsoring-gas/gas-sponsorship-eligibility.md) on the example of using the `paymasterAndData` override to bypass the paymaster middleware to fallback to the user paying the gas fee instead of the gas being subsidized by the paymaster. :::tip Note -Note that if you are using your own middleware, for example a custom `feeDataGetter` using [`withFeeDataGetter`](/packages/aa-core/smart-account-client/withFeeDataGetter.md) method on the provider, then the default `feeDataGetter` middleware is overriden. As you are opting out of using the default middleware, you are also responsible for handling the `UserOperationOverrides` appropriately. +Note that if you are using your own middleware, for example a custom `feeEstimator` using config method on the client, then the default `feeEstimator` middleware is overriden. As you are opting out of using the default middleware, you are also responsible for handling the `UserOperationOverrides` appropriately. ::: ```ts @@ -86,6 +86,6 @@ const txHash = await provider.waitForUserOperationTransaction({ }); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/packages/aa-ethers/provider-adapter/constructor.md b/site/packages/aa-ethers/provider-adapter/constructor.md index 846eef6f4f..96914568ff 100644 --- a/site/packages/aa-ethers/provider-adapter/constructor.md +++ b/site/packages/aa-ethers/provider-adapter/constructor.md @@ -76,4 +76,4 @@ Either: Or: -- `accountProvider: SmartAccountProvider` -- See [SmartAccountProvider](/packages/aa-core/smart-account-client/createSmartAccountClient.md). +- `accountProvider: SmartAccountProvider` -- See [SmartAccountProvider](/packages/aa-core/smart-account-client/index.md). diff --git a/site/snippets/provider.ts b/site/snippets/provider.ts deleted file mode 100644 index 3209146d3d..0000000000 --- a/site/snippets/provider.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { - LightSmartContractAccount, - getDefaultLightAccountFactoryAddress, -} from "@alchemy/aa-accounts"; -import { AlchemyProvider } from "@alchemy/aa-alchemy"; -import { LocalAccountSigner, sepolia, type Hex } from "@alchemy/aa-core"; - -const chain = sepolia; -const PRIVATE_KEY = "0xYourEOAPrivateKey" as Hex; -const owner = LocalAccountSigner.privateKeyToAccountSigner(PRIVATE_KEY); - -export const provider = new AlchemyProvider({ - // get your Alchemy API key at https://dashboard.alchemy.com - apiKey: "ALCHEMY_API_KEY", - chain, -}).connect( - (rpcClient) => - new LightSmartContractAccount({ - rpcClient, - owner, - chain, - factoryAddress: getDefaultLightAccountFactoryAddress(chain), - }) -); diff --git a/site/snippets/sim-uo-example/sim-method.ts b/site/snippets/sim-uo-example/sim-method.ts index 9e43bc7567..61d5b7144f 100644 --- a/site/snippets/sim-uo-example/sim-method.ts +++ b/site/snippets/sim-uo-example/sim-method.ts @@ -1,5 +1,5 @@ import { UserOperationCallData } from "@alchemy/aa-core"; -import { provider } from "../provider.js"; +import { provider } from "../smartAccountClient.js"; const uoStruct: UserOperationCallData = { target: "0xTARGET_ADDRESS", diff --git a/site/snippets/sim-uo-example/sim-middleware.ts b/site/snippets/sim-uo-example/sim-middleware.ts index 579ddb799d..fac715c367 100644 --- a/site/snippets/sim-uo-example/sim-middleware.ts +++ b/site/snippets/sim-uo-example/sim-middleware.ts @@ -1,4 +1,4 @@ -import { provider } from "../provider.js"; +import { provider } from "../smartAccountClient.js"; const providerWithSimulation = provider.withAlchemyUserOpSimulation(); diff --git a/site/snippets/smartAccountClient.ts b/site/snippets/smartAccountClient.ts new file mode 100644 index 0000000000..cbea36e6eb --- /dev/null +++ b/site/snippets/smartAccountClient.ts @@ -0,0 +1,13 @@ +import { createLightAccountClient } from "@alchemy/aa-accounts"; +import { LocalAccountSigner, sepolia, type Hex } from "@alchemy/aa-core"; +import { http } from "viem"; + +const chain = sepolia; +const PRIVATE_KEY = "0xYourEOAPrivateKey" as Hex; +const owner = LocalAccountSigner.privateKeyToAccountSigner(PRIVATE_KEY); + +export const smartAccountClient = await createLightAccountClient({ + transport: http("https://eth-sepolia.alchemyapi.io/v2/ALCHEMY_API_KEY"), + chain, + owner, +}); diff --git a/site/tutorials/batching-transactions.md b/site/tutorials/batching-transactions.md index 9919740717..b36321473f 100644 --- a/site/tutorials/batching-transactions.md +++ b/site/tutorials/batching-transactions.md @@ -39,7 +39,7 @@ When you batch transactions, the transaction actions (`target`s and `calldata`s) The batched UO gets executed by the account calling the `executeBatch` method on the [`SimpleAccount`](https://github.com/eth-infinitism/account-abstraction/blob/ver0.6.0/contracts/samples/SimpleAccount.sol) or [`LightAccount`](https://github.com/alchemyplatform/light-account/blob/v1.0.2/src/LightAccount.sol) smart contracts. `executeBatch` processes the input array of transactions data linearly, guaranteeing the execution order of those transactions to be **sequential**. ::: -## Batching using [`sendUserOperation`](/packages/aa-core/smart-account-client/sendUserOperation.md) +## Batching using [`sendUserOperation`](/packages/aa-core/smart-account-client/actions/sendUserOperation.md) The `SmartAccountProvider` supports passing either a single UO or an array of UOs to `sendUserOperation`. If you pass an array, the provider will batch the transactions into a single User Operation and submit it to the bundler. Let's see an example: @@ -61,11 +61,11 @@ const { hash } = await provider.sendUserOperation([ ]); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: -## Batching using [`sendTransactions`](/packages/aa-core/smart-account-client/sendTransactions.md) +## Batching using [`sendTransactions`](/packages/aa-core/smart-account-client/actions/sendTransactions.md) The `SmartAccountProvider` supports sending UOs and waiting for them to be mined in a transaction via the `sendTransaction` and `sendTransactions` methods. The latter allows for batching in the same way `sendUserOperation`: @@ -87,6 +87,6 @@ const hash = await provider.sendTransactions([ ]); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/tutorials/send-user-operation.md b/site/tutorials/send-user-operation.md index 0ffd8d0993..5265c8a410 100644 --- a/site/tutorials/send-user-operation.md +++ b/site/tutorials/send-user-operation.md @@ -43,7 +43,7 @@ See [Light Account](/packages/aa-accounts/light-account/introduction.md) for mor ## 3. Construct The CallData -The best part of Account Kit is that it abstracts the differences between User Operation calldata and standard Transaction calldata, such that you can pass in typical calldata to [sendUserOperation](/packages/aa-core/smart-account-client/waitForUserOperationTransaction.md) as if it was a transaction sent from your smart account, and we'll wrap it as necessary to generate calldata as it would be as a User Operation. +The best part of Account Kit is that it abstracts the differences between User Operation calldata and standard Transaction calldata, such that you can pass in typical calldata to [sendUserOperation](/packages/aa-core/smart-account-client/actions/waitForUserOperationTransaction.md) as if it was a transaction sent from your smart account, and we'll wrap it as necessary to generate calldata as it would be as a User Operation. The second best part of Account Kit is it's build atop [viem](https://viem.sh/). This means we can leverage utility methods to easily generate calldata, with type safety, using a smart contract's ABI. @@ -53,11 +53,11 @@ Some other helpful viem methods include: [encodeFunctionData](https://viem.sh/do ## 4. Send The User Operation -Now we'll use the connected provider to send a user operation. We'll use the [sendUserOperation](/packages/aa-core/smart-account-client/sendUserOperation.md) method on the provider. +Now we'll use the connected provider to send a user operation. We'll use the [sendUserOperation](/packages/aa-core/smart-account-client/actions/sendUserOperation.md) method on the provider. You can either send ETH to the smart account to pay for User Operation's gas, or you can connect your provider to our Gas Manager using the [withAlchemyGasManager](/packages/aa-alchemy/provider/withAlchemyGasManager.md) method to sponsor the UO's gas. We'll use the latter approach below. You can go to the [Alchemy Dashboard](https://dashboard.alchemy.com/gas-manager/?a=ak-docs) to get a Gas Manager policy ID. -We'll also want to wait for the transaction which contains the User Operation, so that we know the User Operation executed on-chain. We can use the [waitForUserOperationTransaction](/packages/aa-core/smart-account-client/waitForUserOperationTransaction.md) method on provider to do so, as seen below. +We'll also want to wait for the transaction which contains the User Operation, so that we know the User Operation executed on-chain. We can use the [waitForUserOperationTransaction](/packages/aa-core/smart-account-client/actions/waitForUserOperationTransaction.md) method on provider to do so, as seen below. <<< @/snippets/send-uo-example/send-uo.ts diff --git a/site/tutorials/sim-user-operation.md b/site/tutorials/sim-user-operation.md index bb616d183b..8000849de3 100644 --- a/site/tutorials/sim-user-operation.md +++ b/site/tutorials/sim-user-operation.md @@ -42,12 +42,12 @@ There are two ways that Account Kit supports UO simulation on an `AlchemyProvide To simulate User Operations, we must connect the `provider` with the middleware to simulate `UserOperations` before sending them. This can be done in a single line code, as show below! -Then, whenever you call a method on the provider which generates the UO to send (e.g. [`sendUserOperation`](/packages/aa-core/smart-account-client/sendUserOperation), [`sendTransaction`](/packages/aa-core/smart-account-client/sendTransaction), [`sendTransactions`](/packages/aa-core/smart-account-client/sendTransactions), [`buildUserOperation`](/packages/aa-core/smart-account-client/buildUserOperation), or [`buildUserOperationFromTx`](/packages/aa-core/smart-account-client/buildUserOperationFromTx)), the provider will also simulate which assets change as a result of the UO, and if simulation fails, the provider will not send the UO unnecessarily! +Then, whenever you call a method on the provider which generates the UO to send (e.g. [`sendUserOperation`](/packages/aa-core/smart-account-client/actions/sendUserOperation), [`sendTransaction`](/packages/aa-core/smart-account-client/actions/sendTransaction), [`sendTransactions`](/packages/aa-core/smart-account-client/actions/sendTransactions), [`buildUserOperation`](/packages/aa-core/smart-account-client/actions/buildUserOperation), or [`buildUserOperationFromTx`](/packages/aa-core/smart-account-client/actions/buildUserOperationFromTx)), the provider will also simulate which assets change as a result of the UO, and if simulation fails, the provider will not send the UO unnecessarily! ::: code-group <<< @/snippets/sim-uo-example/sim-middleware.ts -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: @@ -58,6 +58,6 @@ You can also selectively simulate UOs by calling the [`simulateUserOperationAsse ::: code-group <<< @/snippets/sim-uo-example/sim-method.ts -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/tutorials/sponsoring-gas/gas-sponsorship-eligibility.md b/site/tutorials/sponsoring-gas/gas-sponsorship-eligibility.md index cbb2357eed..8d61333363 100644 --- a/site/tutorials/sponsoring-gas/gas-sponsorship-eligibility.md +++ b/site/tutorials/sponsoring-gas/gas-sponsorship-eligibility.md @@ -24,7 +24,7 @@ As mentioned from the previous guide on [How to Sponsor Gas for a User Operation But what happens when the user operation you are sending fails to satisfy the criteria set in the gas manager policy? How do you check if the user operation is eligible for gas sponsorship before sending the user operation? -If you do send the user operation that is not eligible for the gas sponsorship under your Gas Manager policy, [`sendUserOperation`](/packages/aa-core/smart-account-client/sendUserOperation.md) or [`sendTransaction`](/packages/aa-core/smart-account-client/sendTransaction.md) will fail due to the error thrown during the [`PaymasterMiddleware`](/packages/aa-core/smart-account-client/withPaymasterMiddleware.md) failure. You can follow the guide below to check for gas sponsorship eligibility in advance. +If you do send the user operation that is not eligible for the gas sponsorship under your Gas Manager policy, [`sendUserOperation`](/packages/aa-core/smart-account-client/actions/sendUserOperation.md) or [`sendTransaction`](/packages/aa-core/smart-account-client/actions/sendTransaction.md) will fail due to the error thrown during the [`PaymasterMiddleware`](/packages/aa-core/smart-account-client/#common-to-both) failure. You can follow the guide below to check for gas sponsorship eligibility in advance. ## 1. How to Check if a User Operation is Eligible for Gas Sponsorship @@ -46,13 +46,13 @@ provider.withAlchemyGasManager({ }); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: -Then, before you call `sendUserOperation` on the provider, you can use [`checkGasSponsorshipEligibility`](/packages/aa-core/smart-account-client/checkGasSponsorshipEligibility.md) to verify the eligibility of the connected account for gas sponsorship concerning the upcoming `UserOperation` (UO) that is intended to be sent. +Then, before you call `sendUserOperation` on the provider, you can use [`checkGasSponsorshipEligibility`](/packages/aa-core/smart-account-client/actions/checkGasSponsorshipEligibility.md) to verify the eligibility of the connected account for gas sponsorship concerning the upcoming `UserOperation` (UO) that is intended to be sent. -Internally, this method invokes [`buildUserOperation`](/packages/aa-core/smart-account-client/buildUserOperation.md), which navigates through the middleware pipeline, including the `PaymasterMiddleware`. Its purpose is to construct the UO struct meant for transmission to the bundler. Following the construction of the UO struct, this function verifies if the resulting structure contains a non-empty `paymasterAndData` field. +Internally, this method invokes [`buildUserOperation`](/packages/aa-core/smart-account-client/actions/buildUserOperation.md), which navigates through the middleware pipeline, including the `PaymasterMiddleware`. Its purpose is to construct the UO struct meant for transmission to the bundler. Following the construction of the UO struct, this function verifies if the resulting structure contains a non-empty `paymasterAndData` field. You can utilize this method before sending the user operation to confirm its eligibility for gas sponsorship. Depending on the outcome, it allows you to tailor the user experience accordingly, based on eligibility. @@ -76,7 +76,7 @@ If you attempt to execute the `sendUserOperation` method for user operations ine This section of the guide elucidates how you can circumvent the `PaymasterMiddleware`, enabling the sending of user operations without gas sponsorship. This functionality permits the sending of user operations where users pay the gas fee themselves via their smart account. -When employing various methods on `SmartAccountProvider` to send user operations (e.g., [`sendUserOperation`](/packages/aa-core/smart-account-client/sendUserOperation.md) or [`sendTransaction`](/packages/aa-core/smart-account-client/sendTransaction.md)), apart from the `UserOperationCallData` or `BatchUserOperationCallData`, you have the option to include an additional parameter named `overrides`. This parameter allows the specification of override values for `maxFeePerGas`, `maxPriorityFeePerGas`, `callGasLimit`, `preVerificationGas`, `verificationGasLimit` or `paymasterAndData`. To bypass the `PaymasterMiddleware`, you can specifically set the `paymasterAndData` override. For example, assigning an empty hex string (`0x`) to the `paymasterAndData` field in the overrides would result in the user operation being sent without the paymaster covering the gas fee, but rather paid from the user's own smart account. +When employing various methods on `SmartAccountProvider` to send user operations (e.g., [`sendUserOperation`](/packages/aa-core/smart-account-client/actions/sendUserOperation.md) or [`sendTransaction`](/packages/aa-core/smart-account-client/actions/sendTransaction.md)), apart from the `UserOperationCallData` or `BatchUserOperationCallData`, you have the option to include an additional parameter named `overrides`. This parameter allows the specification of override values for `maxFeePerGas`, `maxPriorityFeePerGas`, `callGasLimit`, `preVerificationGas`, `verificationGasLimit` or `paymasterAndData`. To bypass the `PaymasterMiddleware`, you can specifically set the `paymasterAndData` override. For example, assigning an empty hex string (`0x`) to the `paymasterAndData` field in the overrides would result in the user operation being sent without the paymaster covering the gas fee, but rather paid from the user's own smart account. ```ts [bypass-paymaster-middleware.ts] // If gas sponsorship ineligible, baypass paymaster middleware by passing in the paymasterAndData override diff --git a/site/tutorials/sponsoring-gas/sponsoring-gas.md b/site/tutorials/sponsoring-gas/sponsoring-gas.md index 642224a668..b381b8e8a9 100644 --- a/site/tutorials/sponsoring-gas/sponsoring-gas.md +++ b/site/tutorials/sponsoring-gas/sponsoring-gas.md @@ -30,7 +30,7 @@ After [installing `aa-sdk`](/overview/getting-started#install-the-packages) in y First, create an `AlchemyProvider`. You'll use this to send UOs and interact with the blockchain. -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts Remember to replace `ALCHEMY_API_KEY` with your Alchemy API key. If you don't have one yet, you can create an API key on the [Alchemy dashboard](https://dashboard.alchemy.com/signup/?a=aa-docs). @@ -78,7 +78,7 @@ const { hash } = await provider.sendUserOperation({ }); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: @@ -111,7 +111,7 @@ const { hash } = await provider.sendUserOperation({ }); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: diff --git a/site/tutorials/transferring-ownership.md b/site/tutorials/transferring-ownership.md index 1c201d4070..e4a5b7e7b2 100644 --- a/site/tutorials/transferring-ownership.md +++ b/site/tutorials/transferring-ownership.md @@ -49,7 +49,7 @@ const newOwner = "0x..."; // the address of the new owner const hash = LightSmartContractAccount.transferOwnership(provider, newOwner); // [!code focus:99] ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts ::: @@ -94,7 +94,7 @@ const { hash: userOperationHash } = provider.sendUserOperation({ }); ``` -<<< @/snippets/provider.ts +<<< @/snippets/smartAccountClient.ts :::