UNPKG

@biconomy/abstractjs

Version:

SDK for Biconomy integration with support for account abstraction, smart accounts, ERC-4337.

30 lines 1.14 kB
import { pad, toHex } from "viem"; import { AccountFactoryAbi } from "../../constants/abi/AccountFactory.js"; /** * Gets the counterfactual address for a MEE Nexus account * * @param params - {@link GetUniversalAddressParams} Configuration for address computation * @param params.publicClient - The public client to use for the read contract * @param params.signerAddress - The address of the EOA signer * @param params.index - Optional account index (defaults to 0) * * @returns Promise resolving to the {@link Address} of the counterfactual account * * @example * const accountAddress = await getNexusAddress({ * publicClient: viemPublicClient, * initData: "0x123...", * index: BigInt(0) * }); */ export const getNexusAddress = async (params) => { const { publicClient, initData, factoryAddress, index = 0n } = params; const salt = pad(toHex(index), { size: 32 }); return await publicClient.readContract({ address: factoryAddress, abi: AccountFactoryAbi, functionName: "computeAccountAddress", args: [initData, salt] }); }; //# sourceMappingURL=getNexusAddress.js.map