Back to All

Alchemy provider chain error

I am trying to create an alchemy provider for account kit but getting

import {
LightSmartContractAccount,
getDefaultLightAccountFactoryAddress,
} from "@alchemy/aa-accounts";
import { AlchemyProvider } from "@alchemy/aa-alchemy";
import { LocalAccountSigner, type Hex } from "@alchemy/aa-core";
import { sepolia } from "viem/chains";

const chain = sepolia;

// Create a provider to send user operations from your smart account
const provider = new AlchemyProvider({
apiKey: "ALCHEMY_API_KEY",
chain,
}).connect(
(rpcClient) =>
new LightSmartContractAccount({
rpcClient,
owner,
chain,
factoryAddress: getDefaultLightAccountFactoryAddress(chain),
})
);

But with the chain getting error :
Type '{ name: string; chainId: number; }' is not assignable to type 'ChainConstants & ChainConfig<ChainFormatters | undefined>'.
Type '{ name: string; chainId: number; }' is missing the following properties from type 'ChainConstants': id, network, nativeCurrency, rpcUrlsts(2322)
schema.d.ts(316, 5): The expected type comes from property 'chain' which is declared here on type '({ entryPointAddress?: string | undefined; opts?: { txMaxRetries?: number | undefined; txRetryIntervalMs?: number | undefined; txRetryMulitplier?: number | undefined; feeOptions?: { ...; } | undefined; } | undefined; } & ({ ...; } | ... 2 more ... | { ...; })) & { ...; }'
(property) chain: ChainConstants & ChainConfig<ChainFormatters | undefined>
No quick fixes available

Here is the package.json file packages

"@alchemy/aa-accounts": "^2.4.0",
"@alchemy/aa-alchemy": "^2.4.0",
"@alchemy/aa-core": "^2.3.1",
"axios": "^1.6.7",
"dotenv": "^16.4.1",
"ethers": "^6.11.0",
"node-fetch": "^3.3.2",
"node-forge": "^1.3.1",
"viem": "^2.7.10"

},

Node Version: v18.17.1

ReadMe