Creates a Base Account SDK instance that provides an EIP-1193 compliant Ethereum provider and additional account management functionality. This is the primary entry point for integrating Base Account into your application.
When true (default), enables Auto Spend Permissions for sub-accounts. This allows automatic transfers from the user’s Base Account to the sub-account when funds are missing and attempts background transactions using existing spend permissions. Set to false to disable this behavior. Learn more in Auto Spend Permissions.
Sets the function for determining the owner account. The function should return a Promise resolving to an object with an account property that is either a LocalAccount, WebAuthnAccount, or null.
Copy
Ask AI
import { createBaseAccountSDK } from '@base-org/account';import { base } from 'viem/chains';const sdk = createBaseAccountSDK({ appName: 'My DApp', appLogoUrl: 'https://mydapp.com/logo.png', appChainIds: [base.id],});const provider = sdk.getProvider();
The SDK is fully typed for TypeScript development:
Report incorrect code
Copy
Ask AI
import type { CreateProviderOptions, BaseAccountSDK, ProviderInterface, ToOwnerAccountFn} from '@base-org/account';import { LocalAccount } from 'viem';const toOwnerAccount: ToOwnerAccountFn = async () => { // Your logic to get the owner account const ownerAccount: LocalAccount | null = getOwnerAccount(); return { account: ownerAccount };};const options: CreateProviderOptions = { appName: 'Typed App', appChainIds: [8453], subAccounts: { toOwnerAccount }};const sdk: BaseAccountSDK = createBaseAccountSDK(options);const provider: ProviderInterface = sdk.getProvider();
The SDK automatically manages Cross-Origin-Opener-Policy validation and telemetry initialization. Make sure your application’s headers allow popup windows if using the default wallet interface.
The createBaseAccountSDK function is the primary entry point for Base Account integration. It provides both a standard EIP-1193 provider and advanced features like sub-account management and gasless transactions.