diff --git a/packages/accounts/src/kernel-zerodev/README.md b/packages/accounts/src/kernel-zerodev/README.md index a324c51e8a..25c371bf43 100644 --- a/packages/accounts/src/kernel-zerodev/README.md +++ b/packages/accounts/src/kernel-zerodev/README.md @@ -50,7 +50,6 @@ const provider = new KernelAccountProvider( new KernelSmartContractAccount({ owner, index: 0n, - entryPointAddress, chain, factoryAddress: KERNEL_ACCOUNT_FACTORY_ADDRESS, rpcClient, diff --git a/packages/accounts/src/kernel-zerodev/__tests__/account.test.ts b/packages/accounts/src/kernel-zerodev/__tests__/account.test.ts index 327564db00..d679d0c756 100644 --- a/packages/accounts/src/kernel-zerodev/__tests__/account.test.ts +++ b/packages/accounts/src/kernel-zerodev/__tests__/account.test.ts @@ -25,7 +25,6 @@ describe("Kernel Account Tests", () => { validatorAddress: "0x180D6465F921C7E0DEA0040107D342c87455fFF5" as Address, accountFactoryAddress: "0x5D006d3880645ec6e254E18C1F879DAC9Dd71A39" as Address, - entryPointAddress, }; const owner = LocalAccountSigner.privateKeyToAccountSigner(config.privateKey); @@ -51,7 +50,6 @@ describe("Kernel Account Tests", () => { function account(index: bigint, owner = mockOwner) { const accountParams: KernelSmartAccountParams = { rpcClient: provider.rpcClient, - entryPointAddress: config.entryPointAddress, chain: config.chain, owner: owner, factoryAddress: config.accountFactoryAddress, diff --git a/packages/accounts/src/kernel-zerodev/e2e-tests/kernel-account.test.ts b/packages/accounts/src/kernel-zerodev/e2e-tests/kernel-account.test.ts index e99916519e..3fdc032388 100644 --- a/packages/accounts/src/kernel-zerodev/e2e-tests/kernel-account.test.ts +++ b/packages/accounts/src/kernel-zerodev/e2e-tests/kernel-account.test.ts @@ -75,7 +75,6 @@ describe("Kernel Account Tests", () => { function account(index: bigint, owner = mockOwner) { const accountParams: KernelSmartAccountParams = { rpcClient: provider.rpcClient, - entryPointAddress: config.entryPointAddress, chain: config.chain, owner: owner, factoryAddress: config.accountFactoryAddress, diff --git a/packages/accounts/src/light-account/__tests__/account.test.ts b/packages/accounts/src/light-account/__tests__/account.test.ts index d35360bf5e..22a2f2abe3 100644 --- a/packages/accounts/src/light-account/__tests__/account.test.ts +++ b/packages/accounts/src/light-account/__tests__/account.test.ts @@ -8,6 +8,7 @@ import { import { polygonMumbai, type Chain } from "viem/chains"; import { describe, it } from "vitest"; import { LightSmartContractAccount } from "../account.js"; +import { getDefaultLightAccountFactoryAddress } from "../utils.js"; describe("Light Account Tests", () => { const dummyMnemonic = @@ -91,7 +92,7 @@ const givenConnectedProvider = ({ entryPointAddress: dummyEntryPointAddress, chain, owner, - factoryAddress: "0xLIGHT_ACCOUNT_FACTORY_ADDRESS", + factoryAddress: getDefaultLightAccountFactoryAddress(chain), rpcClient: provider, }); diff --git a/packages/accounts/src/light-account/e2e-tests/light-account.test.ts b/packages/accounts/src/light-account/e2e-tests/light-account.test.ts index 87c11cf948..068818abdb 100644 --- a/packages/accounts/src/light-account/e2e-tests/light-account.test.ts +++ b/packages/accounts/src/light-account/e2e-tests/light-account.test.ts @@ -1,7 +1,6 @@ import { LocalAccountSigner, SmartAccountProvider, - getDefaultEntryPointAddress, type SmartAccountSigner, } from "@alchemy/aa-core"; import { isAddress, type Address, type Chain, type Hash } from "viem"; @@ -17,8 +16,6 @@ import { } from "./constants.js"; const chain = sepolia; -const entryPointAddress = getDefaultEntryPointAddress(chain); -const factoryAddress = getDefaultLightAccountFactoryAddress(chain); describe("Light Account Tests", () => { const owner: SmartAccountSigner = LocalAccountSigner.mnemonicToAccountSigner( @@ -194,10 +191,9 @@ const givenConnectedProvider = ({ }).connect( (provider) => new LightSmartContractAccount({ - entryPointAddress, chain, owner, - factoryAddress, + factoryAddress: getDefaultLightAccountFactoryAddress(chain), rpcClient: provider, accountAddress, }) diff --git a/packages/alchemy/e2e-tests/simple-account.test.ts b/packages/alchemy/e2e-tests/simple-account.test.ts index ea430c76a2..4381fec068 100644 --- a/packages/alchemy/e2e-tests/simple-account.test.ts +++ b/packages/alchemy/e2e-tests/simple-account.test.ts @@ -1,6 +1,5 @@ import { SimpleSmartContractAccount, - getDefaultEntryPointAddress, getDefaultSimpleAccountFactoryAddress, type SmartAccountSigner, } from "@alchemy/aa-core"; @@ -11,8 +10,6 @@ import { AlchemyProvider } from "../src/provider.js"; import { API_KEY, OWNER_MNEMONIC, PAYMASTER_POLICY_ID } from "./constants.js"; const chain = polygonMumbai; -const entryPointAddress = getDefaultEntryPointAddress(chain); -const factoryAddress = getDefaultSimpleAccountFactoryAddress(chain); describe("Simple Account Tests", () => { const ownerAccount = mnemonicToAccount(OWNER_MNEMONIC); @@ -174,10 +171,9 @@ const givenConnectedProvider = ({ }).connect( (provider) => new SimpleSmartContractAccount({ - entryPointAddress, chain, owner, - factoryAddress, + factoryAddress: getDefaultSimpleAccountFactoryAddress(chain), rpcClient: provider, accountAddress, }) diff --git a/packages/alchemy/src/__tests__/provider.test.ts b/packages/alchemy/src/__tests__/provider.test.ts index 809c229cae..936ea38623 100644 --- a/packages/alchemy/src/__tests__/provider.test.ts +++ b/packages/alchemy/src/__tests__/provider.test.ts @@ -87,7 +87,7 @@ const givenConnectedProvider = ({ entryPointAddress: dummyEntryPointAddress, chain, owner, - factoryAddress: "0xSIMPLE_ACCOUNT_FACTORY_ADDRESS", + factoryAddress: AACoreModule.getDefaultSimpleAccountFactoryAddress(chain), rpcClient: provider, }); diff --git a/packages/core/e2e-tests/simple-account.test.ts b/packages/core/e2e-tests/simple-account.test.ts index 8cb90a2b1d..4aad60658b 100644 --- a/packages/core/e2e-tests/simple-account.test.ts +++ b/packages/core/e2e-tests/simple-account.test.ts @@ -3,8 +3,7 @@ import { generatePrivateKey } from "viem/accounts"; import { polygonMumbai } from "viem/chains"; import { SimpleSmartContractAccount } from "../src/account/simple.js"; import { - getDefaultEntryPointAddress, - getDefaultSimpleAccountFactoryAddressAddress, + getDefaultSimpleAccountFactoryAddress, type SmartAccountSigner, } from "../src/index.js"; import { SmartAccountProvider } from "../src/provider/base.js"; @@ -12,8 +11,6 @@ import { LocalAccountSigner } from "../src/signer/local-account.js"; import { API_KEY, OWNER_MNEMONIC, RPC_URL } from "./constants.js"; const chain = polygonMumbai; -const entryPointAddress = getDefaultEntryPointAddress(chain); -const factoryAddress = getDefaultSimpleAccountFactoryAddressAddress(chain); describe("Simple Account Tests", () => { const owner: SmartAccountSigner = @@ -77,10 +74,9 @@ const givenConnectedProvider = ({ }).connect( (provider) => new SimpleSmartContractAccount({ - entryPointAddress, chain, owner, - factoryAddress, + factoryAddress: getDefaultSimpleAccountFactoryAddress(chain), rpcClient: provider, accountAddress, }) diff --git a/packages/core/src/account/__tests__/simple.test.ts b/packages/core/src/account/__tests__/simple.test.ts index 5616f6d0f0..b5c0c3db02 100644 --- a/packages/core/src/account/__tests__/simple.test.ts +++ b/packages/core/src/account/__tests__/simple.test.ts @@ -1,5 +1,6 @@ import { polygonMumbai, type Chain } from "viem/chains"; import { describe, it } from "vitest"; +import { getDefaultSimpleAccountFactoryAddress } from "../../index.js"; import { SmartAccountProvider } from "../../provider/base.js"; import { LocalAccountSigner } from "../../signer/local-account.js"; import { type SmartAccountSigner } from "../../signer/types.js"; @@ -11,6 +12,7 @@ describe("Account Simple Tests", () => { "test test test test test test test test test test test test"; const owner: SmartAccountSigner = LocalAccountSigner.mnemonicToAccountSigner(dummyMnemonic); + const chain = polygonMumbai; it("should correctly sign the message", async () => { @@ -55,10 +57,9 @@ const givenConnectedProvider = ({ chain, }).connect((provider) => { const account = new SimpleSmartContractAccount({ - entryPointAddress: "0xENTRYPOINT_ADDRESS", chain, owner, - factoryAddress: "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef", + factoryAddress: getDefaultSimpleAccountFactoryAddress(chain), rpcClient: provider, }); diff --git a/packages/core/src/account/base.ts b/packages/core/src/account/base.ts index 98916169a7..b4f9bcb0bb 100644 --- a/packages/core/src/account/base.ts +++ b/packages/core/src/account/base.ts @@ -19,6 +19,7 @@ import { Logger } from "../logger.js"; import type { SmartAccountSigner } from "../signer/types.js"; import { wrapSignatureWith6492 } from "../signer/utils.js"; import type { BatchUserOperationCallData } from "../types.js"; +import { getDefaultEntryPointAddress } from "../utils/defaults.js"; import type { ISmartContractAccount, SignTypedDataParams } from "./types.js"; export enum DeploymentState { @@ -31,10 +32,24 @@ export interface BaseSmartAccountParams< TTransport extends SupportedTransports = Transport > { rpcClient: string | PublicErc4337Client; - entryPointAddress: Address; factoryAddress: Address; - owner?: SmartAccountSigner | undefined; chain: Chain; + + /** + * The address of the entry point contract. + * If not provided, the default entry point contract will be used. + * Check out https://docs.alchemy.com/reference/eth-supportedentrypoints for all the supported entrypoints + */ + entryPointAddress?: Address; + + /** + * Owner account signer for the account if there is one. + */ + owner?: SmartAccountSigner | undefined; + + /** + * The address of the account if it is already deployed. + */ accountAddress?: Address; } @@ -57,7 +72,8 @@ export abstract class BaseSmartContractAccount< | PublicErc4337Client; constructor(params: BaseSmartAccountParams) { - this.entryPointAddress = params.entryPointAddress; + this.entryPointAddress = + params.entryPointAddress ?? getDefaultEntryPointAddress(params.chain); const rpcUrl = typeof params.rpcClient === "string" @@ -99,7 +115,7 @@ export abstract class BaseSmartContractAccount< this.owner = params.owner; this.entryPoint = getContract({ - address: params.entryPointAddress, + address: this.entryPointAddress, abi: EntryPointAbi, // Need to cast this as PublicClient or else it breaks ABI typing. // This is valid because our PublicClient is a subclass of PublicClient diff --git a/packages/ethers/e2e-tests/simple-account.test.ts b/packages/ethers/e2e-tests/simple-account.test.ts index 9b1db2743a..1d911e99c1 100644 --- a/packages/ethers/e2e-tests/simple-account.test.ts +++ b/packages/ethers/e2e-tests/simple-account.test.ts @@ -1,7 +1,6 @@ import { SimpleSmartContractAccount, getChain, - getDefaultEntryPointAddress, getDefaultSimpleAccountFactoryAddress, type Address, } from "@alchemy/aa-core"; @@ -13,8 +12,6 @@ import { convertWalletToAccountSigner } from "../src/utils.js"; import { API_KEY, OWNER_MNEMONIC, RPC_URL } from "./constants.js"; const chain = polygonMumbai; -const entryPointAddress = getDefaultEntryPointAddress(chain); -const factoryAddress = getDefaultSimpleAccountFactoryAddress(chain); describe("Simple Account Tests", async () => { const alchemy = new Alchemy({ @@ -74,10 +71,9 @@ const givenConnectedProvider = ({ EthersProviderAdapter.fromEthersProvider(alchemyProvider).connectToAccount( (rpcClient) => new SimpleSmartContractAccount({ - entryPointAddress, chain: getChain(alchemyProvider.network.chainId), owner: convertWalletToAccountSigner(owner), - factoryAddress, + factoryAddress: getDefaultSimpleAccountFactoryAddress(chain), rpcClient, accountAddress, }) diff --git a/packages/ethers/src/__tests__/provider-adapter.test.ts b/packages/ethers/src/__tests__/provider-adapter.test.ts index d8816d6bac..303c3526b3 100644 --- a/packages/ethers/src/__tests__/provider-adapter.test.ts +++ b/packages/ethers/src/__tests__/provider-adapter.test.ts @@ -1,4 +1,8 @@ -import { SimpleSmartContractAccount, getChain } from "@alchemy/aa-core"; +import { + SimpleSmartContractAccount, + getChain, + getDefaultSimpleAccountFactoryAddress, +} from "@alchemy/aa-core"; import { Wallet } from "@ethersproject/wallet"; import { Alchemy, Network, type AlchemyProvider } from "alchemy-sdk"; import { EthersProviderAdapter } from "../../src/provider-adapter.js"; @@ -37,10 +41,11 @@ const givenConnectedProvider = ({ EthersProviderAdapter.fromEthersProvider(alchemyProvider).connectToAccount( (rpcClient) => { const account = new SimpleSmartContractAccount({ - entryPointAddress: "0xENTRYPOINT_ADDRESS", chain: getChain(alchemyProvider.network.chainId), owner: convertWalletToAccountSigner(owner), - factoryAddress: "0xSIMPLE_ACCOUNT_FACTORY_ADDRESS", + factoryAddress: getDefaultSimpleAccountFactoryAddress( + getChain(alchemyProvider.network.chainId) + ), rpcClient, }); diff --git a/site/packages/aa-ethers/provider-adapter/introduction.md b/site/packages/aa-ethers/provider-adapter/introduction.md index da953a39ca..3f27618753 100644 --- a/site/packages/aa-ethers/provider-adapter/introduction.md +++ b/site/packages/aa-ethers/provider-adapter/introduction.md @@ -29,6 +29,12 @@ Notable differences between `EthersProviderAdapter` and `JsonRpcProvider` are im ```ts [example.ts] import { provider } from "./ethers-provider"; +import { + LightSmartContractAccount, + getDefaultLightAccountFactoryAddress, +} from "@alchemy/aa-accounts"; +import { LocalAccountSigner, type SmartAccountSigner } from "@alchemy/aa-core"; +import { sepolia } from "viem/chains"; // [!code focus:99] // EIP-1193 compliant requests const chainId = await provider.send("eth_chainId", []); @@ -43,9 +49,8 @@ const owner: SmartAccountSigner = LocalAccountSigner.mnemonicToAccountSigner( const signer = provider.connectToAccount( (rpcClient) => new LightSmartContractAccount({ - entryPointAddress: entryPointAddress, - chain: polygonMumbai, - factoryAddress: "0xfactoryAddress", + chain: sepolia, + factoryAddress: getDefaultLightAccountFactoryAddress(sepolia), rpcClient, owner, }) diff --git a/site/smart-accounts/signers/capsule.md b/site/smart-accounts/signers/capsule.md index 0a2e5cac72..d81ee2e9f2 100644 --- a/site/smart-accounts/signers/capsule.md +++ b/site/smart-accounts/signers/capsule.md @@ -80,18 +80,16 @@ import { sepolia } from "viem/chains"; import { capsuleSigner } from "./capsule"; const chain = sepolia; -const entryPointAddress = getDefaultEntryPointAddress(chain); -const factoryAddress = getDefaultLightAccountFactoryAddress(chain); + const provider = new AlchemyProvider({ apiKey: "ALCHEMY_API_KEY", chain, }).connect( (rpcClient) => new LightSmartContractAccount({ - entryPointAddress, - chain: rpcClient.chain, + chain, owner: capsuleSigner, - factoryAddress, + factoryAddress: getDefaultLightAccountFactoryAddress(chain), rpcClient, }) ); diff --git a/site/smart-accounts/signers/dynamic.md b/site/smart-accounts/signers/dynamic.md index 3be8b2d30d..4487871ac8 100644 --- a/site/smart-accounts/signers/dynamic.md +++ b/site/smart-accounts/signers/dynamic.md @@ -91,18 +91,16 @@ import { sepolia } from "viem/chains"; import { dynamicSigner } from "./dynamic"; const chain = sepolia; -const entryPointAddress = getDefaultEntryPointAddress(chain); -const factoryAddress = getDefaultLightAccountFactoryAddress(chain); + const provider = new AlchemyProvider({ apiKey: "ALCHEMY_API_KEY", chain, }).connect( (rpcClient) => new LightSmartContractAccount({ - entryPointAddress, - chain: rpcClient.chain, + chain, owner: dynamicSigner, - factoryAddress, + factoryAddress: getDefaultLightAccountFactoryAddress(chain), rpcClient, }) ); diff --git a/site/smart-accounts/signers/fireblocks.md b/site/smart-accounts/signers/fireblocks.md index d0a3c5cf20..32914510ea 100644 --- a/site/smart-accounts/signers/fireblocks.md +++ b/site/smart-accounts/signers/fireblocks.md @@ -55,7 +55,10 @@ Let's see it in action with `aa-alchemy` and `LightSmartContractAccount` from `a ```ts [example.ts] import { AlchemyProvider } from "@alchemy/aa-alchemy"; -import { LightSmartContractAccount } from "@alchemy/aa-accounts"; +import { + LightSmartContractAccount, + getDefaultLightAccountFactoryAddress, +} from "@alchemy/aa-accounts"; import { sepolia } from "viem/chains"; import { fireblocksSigner } from "./fireblocks"; @@ -66,10 +69,9 @@ const provider = new AlchemyProvider({ }).connect( (rpcClient) => new LightSmartContractAccount({ - entryPointAddress: "0x...", chain: rpcClient.chain, owner: fireblocksSigner, - factoryAddress: "0x...", + factoryAddress: getDefaultLightAccountFactoryAddress(chain), rpcClient, }) ); diff --git a/site/smart-accounts/signers/lit.md b/site/smart-accounts/signers/lit.md index 2f34c8c5d2..9e3c7588f6 100644 --- a/site/smart-accounts/signers/lit.md +++ b/site/smart-accounts/signers/lit.md @@ -77,7 +77,10 @@ We can link our `SmartAccountSigner` to a `LightSmartContractAccount` from `aa-a ```ts [example.ts] import { AlchemyProvider } from "@alchemy/aa-alchemy"; -import { LightSmartContractAccount } from "@alchemy/aa-accounts"; +import { + LightSmartContractAccount, + getDefaultLightAccountFactoryAddress, +} from "@alchemy/aa-accounts"; import { litSigner } from "./lit"; const chain = sepolia; @@ -87,10 +90,9 @@ const provider = new AlchemyProvider({ }).connect( (rpcClient) => new LightSmartContractAccount({ - entryPointAddress: "0x...", - chain: rpcClient.chain, + chain, owner: litSigner, - factoryAddress: "0x...", + factoryAddress: getDefaultLightAccountFactoryAddress(chain), rpcClient, }) ); diff --git a/site/smart-accounts/signers/magic.md b/site/smart-accounts/signers/magic.md index 4490dd6430..4d0927a8a7 100644 --- a/site/smart-accounts/signers/magic.md +++ b/site/smart-accounts/signers/magic.md @@ -61,8 +61,6 @@ import { sepolia } from "viem/chains"; import { createMagicSigner } from "./magic"; const chain = sepolia; -const entryPointAddress = getDefaultEntryPointContract(chain); -const factoryAddress = getDefaultLightAccountFactory(chain); // NOTE: the below is async because it depends on creating a magic signer. You can choose to break that up how you want // eg. use a useEffect + useState to create the signer and then pass it down to the provider @@ -75,7 +73,7 @@ const provider = new AlchemyProvider({ entryPointAddress, chain: rpcClient.chain, owner: await createMagicSigner(), - factoryAddress, + factoryAddress: getDefaultLightAccountFactoryAddress(chain), rpcClient, }) ); diff --git a/site/smart-accounts/signers/portal.md b/site/smart-accounts/signers/portal.md index 511bdefda6..7754184cb5 100644 --- a/site/smart-accounts/signers/portal.md +++ b/site/smart-accounts/signers/portal.md @@ -55,7 +55,10 @@ Let's see it in action with `aa-alchemy` and `LightSmartContractAccount` from `a ```ts [example.ts] import { AlchemyProvider } from "@alchemy/aa-alchemy"; -import { LightSmartContractAccount } from "@alchemy/aa-accounts"; +import { + LightSmartContractAccount, + getDefaultLightAccountFactoryAddress, +} from "@alchemy/aa-accounts"; import { polygonMumbai } from "viem/chains"; import { portalSigner } from "./portalSigner"; @@ -66,10 +69,9 @@ const provider = new AlchemyProvider({ }).connect( (rpcClient) => new LightSmartContractAccount({ - entryPointAddress: ENTRY_POINT_CONTRACT_ADDRESS, - chain: rpcClient.chain, + chain, owner: portalSigner, - factoryAddress: FACTORY_CONTRACT_ADDRESS, + factoryAddress: getDefaultLightAccountFactoryAddress(chain), rpcClient, }) ); diff --git a/site/smart-accounts/signers/turnkey.md b/site/smart-accounts/signers/turnkey.md index 258ea2c4e5..6851fcf413 100644 --- a/site/smart-accounts/signers/turnkey.md +++ b/site/smart-accounts/signers/turnkey.md @@ -69,18 +69,16 @@ import { newTurnkeySigner } from "./turnkey"; async function main() { const owner = await newTurnkeySigner(); const chain = sepolia; - const entryPointAddress = getDefaultEntryPointAddress(chain); - const factoryAddress = getDefaultLightAccountFactoryAddress(chain); + const provider = new AlchemyProvider({ apiKey: "ALCHEMY_API_KEY", chain, }).connect( (rpcClient) => new LightSmartContractAccount({ - entryPointAddress, - chain: rpcClient.chain, + chain, owner, - factoryAddress, + factoryAddress: getDefaultLightAccountFactoryAddress(chain), rpcClient, }) ); diff --git a/site/smart-accounts/signers/web3auth.md b/site/smart-accounts/signers/web3auth.md index d4b1664023..bce597dbb8 100644 --- a/site/smart-accounts/signers/web3auth.md +++ b/site/smart-accounts/signers/web3auth.md @@ -61,18 +61,16 @@ import { sepolia } from "viem/chains"; import { web3authSigner } from "./web3auth"; const chain = sepolia; -const entryPointAddress = getDefaultEntryPointAddress(chain); -const factoryAddress = getDefaultLightAccountFactoryAddress(chain); + const provider = new AlchemyProvider({ apiKey: "ALCHEMY_API_KEY", chain, }).connect( (rpcClient) => new LightSmartContractAccount({ - entryPointAddress, - chain: rpcClient.chain, + chain, owner: web3authSigner, - factoryAddress, + factoryAddress: getDefaultLightAccountFactoryAddress(chain), rpcClient, }) ); diff --git a/site/snippets/account-core.ts b/site/snippets/account-core.ts index 56187b6aae..9689292e8d 100644 --- a/site/snippets/account-core.ts +++ b/site/snippets/account-core.ts @@ -4,7 +4,6 @@ import { LocalAccountSigner, SimpleSmartContractAccount, SmartAccountProvider, - getDefaultEntryPointAddress, getDefaultSimpleAccountFactoryAddress, type SmartAccountSigner, } from "@alchemy/aa-core"; @@ -17,21 +16,18 @@ const owner: SmartAccountSigner = LocalAccountSigner.mnemonicToAccountSigner(MNEMONIC); const chain = polygonMumbai; -const entryPointAddress = getDefaultEntryPointAddress(chain); -const factoryAddress = getDefaultSimpleAccountFactoryAddress(chain); // 2. initialize the provider and connect it to the account const provider = new SmartAccountProvider({ // the demo key below is public and rate-limited, it's better to create a new one // you can get started with a free account @ https://www.alchemy.com/ rpcProvider: "https://polygon-mumbai.g.alchemy.com/v2/demo", - chain: polygonMumbai, + chain, }).connect( (rpcClient) => new SimpleSmartContractAccount({ - entryPointAddress, - chain: polygonMumbai, - factoryAddress, + chain, + factoryAddress: getDefaultSimpleAccountFactoryAddress(chain), rpcClient, owner, // optionally if you already know the account's address diff --git a/site/snippets/core-provider.ts b/site/snippets/core-provider.ts index 6440e04222..3cc4faea51 100644 --- a/site/snippets/core-provider.ts +++ b/site/snippets/core-provider.ts @@ -6,15 +6,12 @@ import { LocalAccountSigner, SmartAccountProvider, SmartAccountSigner, - getDefaultEntryPointAddress, } from "@alchemy/aa-core"; import { polygonMumbai } from "viem/chains"; const chain = polygonMumbai; const owner: SmartAccountSigner = LocalAccountSigner.mnemonicToAccountSigner(YOUR_OWNER_MNEMONIC); -const entryPointAddress = getDefaultEntryPointAddress(chain); -const factoryAddress = getDefaultLightAccountFactoryAddress(chain); export const provider = new SmartAccountProvider({ rpcProvider: "https://polygon-mumbai.g.alchemy.com/v2/demo", @@ -22,9 +19,8 @@ export const provider = new SmartAccountProvider({ }).connect( (rpcClient) => new LightSmartContractAccount({ - entryPointAddress, chain, - factoryAddress, + factoryAddress: getDefaultLightAccountFactoryAddress(chain), rpcClient, owner, }) diff --git a/site/snippets/ethers-signer.ts b/site/snippets/ethers-signer.ts index 8fb7c657f4..385f0e5f77 100644 --- a/site/snippets/ethers-signer.ts +++ b/site/snippets/ethers-signer.ts @@ -2,11 +2,7 @@ import { LightSmartContractAccount, getDefaultLightAccountFactoryAddress, } from "@alchemy/aa-accounts"; -import { - LocalAccountSigner, - SmartAccountSigner, - getDefaultEntryPointAddress, -} from "@alchemy/aa-core"; +import { LocalAccountSigner, SmartAccountSigner } from "@alchemy/aa-core"; import { polygonMumbai } from "viem/chains"; import { provider } from "./ethers-provider.js"; @@ -15,15 +11,12 @@ const owner: SmartAccountSigner = LocalAccountSigner.mnemonicToAccountSigner( ); const chain = polygonMumbai; -const entryPointAddress = getDefaultEntryPointAddress(chain); -const factoryAddress = getDefaultLightAccountFactoryAddress(chain); export const signer = provider.connectToAccount( (rpcClient) => new LightSmartContractAccount({ - entryPointAddress, chain, - factoryAddress, + factoryAddress: getDefaultLightAccountFactoryAddress(chain), rpcClient, owner, }) diff --git a/site/snippets/light-account.ts b/site/snippets/light-account.ts index d8b5ae543a..b3187ba2a9 100644 --- a/site/snippets/light-account.ts +++ b/site/snippets/light-account.ts @@ -29,7 +29,6 @@ const provider = new AlchemyProvider({ }).connect( (rpcClient) => new LightSmartContractAccount({ - entryPointAddress, chain, owner: eoaSigner, factoryAddress, diff --git a/site/snippets/privy.ts b/site/snippets/privy.ts index bdb90df411..ebce55a6e7 100644 --- a/site/snippets/privy.ts +++ b/site/snippets/privy.ts @@ -2,7 +2,10 @@ * This example assumes your app is wrapped with the `PrivyProvider` and * is configured to create embedded wallets for users upon login. */ -import { LightSmartContractAccount } from "@alchemy/aa-accounts"; +import { + LightSmartContractAccount, + getDefaultLightAccountFactoryAddress, +} from "@alchemy/aa-accounts"; import { AlchemyProvider } from "@alchemy/aa-alchemy"; import { WalletClientSigner, type SmartAccountSigner } from "@alchemy/aa-core"; import { useWallets } from "@privy-io/react-auth"; @@ -44,10 +47,9 @@ export const provider = new AlchemyProvider({ }).connect( (rpcClient) => new LightSmartContractAccount({ - entryPointAddress: "0x...", chain: rpcClient.chain, owner: privySigner, - factoryAddress: "0x...", + factoryAddress: getDefaultLightAccountFactoryAddress(rpcClient.chain), rpcClient, }) ); diff --git a/site/snippets/provider.ts b/site/snippets/provider.ts index ee863aeb54..3e79a57318 100644 --- a/site/snippets/provider.ts +++ b/site/snippets/provider.ts @@ -3,19 +3,13 @@ import { getDefaultLightAccountFactoryAddress, } from "@alchemy/aa-accounts"; import { AlchemyProvider } from "@alchemy/aa-alchemy"; -import { - LocalAccountSigner, - getDefaultEntryPointAddress, - type SmartAccountSigner, -} from "@alchemy/aa-core"; +import { LocalAccountSigner, type SmartAccountSigner } from "@alchemy/aa-core"; import { sepolia } from "viem/chains"; const chain = sepolia; const PRIVATE_KEY = "0xYourEOAPrivateKey"; const eoaSigner: SmartAccountSigner = LocalAccountSigner.privateKeyToAccountSigner(`0x${PRIVATE_KEY}`); -const entryPointAddress = getDefaultEntryPointAddress(chain); -const factoryAddress = getDefaultLightAccountFactoryAddress(chain); export const provider = new AlchemyProvider({ apiKey: "ALCHEMY_API_KEY", // replace with your alchemy api key of the Alchemy app associated with the Gas Manager, get yours at https://dashboard.alchemy.com/ @@ -23,10 +17,9 @@ export const provider = new AlchemyProvider({ }).connect( (rpcClient) => new LightSmartContractAccount({ - entryPointAddress: entryPointAddress, - chain: rpcClient.chain, + chain, owner: eoaSigner, - factoryAddress, + factoryAddress: getDefaultLightAccountFactoryAddress(chain), rpcClient, }) );