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.
Controls how sub-accounts are funded. Defaults to 'spend-permissions'.
'spend-permissions': Routes through universal account if no spend permissions exist, handles insufficient balance errors automatically. Learn more in Auto Spend Permissions
'manual': Direct execution from sub-account without automatic fallbacks
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.