|
| 1 | +# https://docs.base.org/base-account/llms-full.txt |
| 2 | + |
| 3 | +## Base Account — Deep Guide for LLMs |
| 4 | + |
| 5 | +> Base Account is a passkey‑secured, ERC‑4337 smart wallet with universal sign‑in, USDC payments, sponsored gas, batch transactions, spend permissions, and sub‑accounts. |
| 6 | + |
| 7 | +### What you can do here |
| 8 | +- Add Base Account to web and mobile apps |
| 9 | +- Authenticate users with SIWE + ERC‑6492 |
| 10 | +- Accept USDC with Base Pay and sponsor gas with a paymaster |
| 11 | +- Use batch transactions and ERC‑20 gas payments |
| 12 | +- Grant revocable spend permissions and create app‑scoped sub‑accounts |
| 13 | + |
| 14 | +## Minimal Critical Code (provider + pay) |
| 15 | +```ts |
| 16 | +import { createBaseAccountSDK, pay, getPaymentStatus } from '@base-org/account' |
| 17 | + |
| 18 | +const provider = createBaseAccountSDK().getProvider() |
| 19 | +const { id } = await pay({ amount: '5.00', to: '0xRecipient', testnet: true }) |
| 20 | +const { status } = await getPaymentStatus({ id }) |
| 21 | +``` |
| 22 | + |
| 23 | +## Navigation (with brief descriptions) |
| 24 | + |
| 25 | +### Introduction |
| 26 | +- [What is Base Account?](./overview/what-is-base-account) — Overview |
| 27 | + |
| 28 | +### Quickstart |
| 29 | +- [Web (Next.js)](./quickstart/web) — Web integration |
| 30 | +- [Web (React)](./quickstart/web-react) — React example |
| 31 | +- [React Native Integration](./quickstart/mobile-integration) — Mobile |
| 32 | + |
| 33 | +### Guides |
| 34 | +- [Authenticate Users](./guides/authenticate-users) — SIWE + ERC‑6492 |
| 35 | +- [Accept Payments](./guides/accept-payments) — Base Pay |
| 36 | +- [Batch Transactions](./improve-ux/batch-transactions) — Multi‑call |
| 37 | +- [Paymasters](./improve-ux/sponsor-gas/paymasters) — Sponsor gas |
| 38 | +- [ERC‑20 Paymasters](./improve-ux/sponsor-gas/erc20-paymasters) — ERC‑20 gas |
| 39 | +- [Spend Permissions](./improve-ux/spend-permissions) — Spending |
| 40 | +- [Sub‑Accounts](./improve-ux/sub-accounts) — App‑scoped accounts |
| 41 | +- [MagicSpend](./improve-ux/magic-spend) — Coinbase balance spend |
| 42 | +- [Sign & Verify Data](./guides/sign-and-verify-typed-data) — Signatures |
| 43 | + |
| 44 | +### Framework Integrations |
| 45 | +- [Wagmi Setup](./framework-integrations/wagmi/setup) — Wagmi |
| 46 | +- [Wagmi Sign in with Base](./framework-integrations/wagmi/sign-in-with-base) — Auth |
| 47 | +- [Wagmi Base Pay](./framework-integrations/wagmi/base-pay) — Payments |
| 48 | +- [Wagmi Other Use Cases](./framework-integrations/wagmi/other-use-cases) — Patterns |
| 49 | +- [Privy Setup](./framework-integrations/privy/setup) — Privy |
| 50 | +- [Privy Sub‑Accounts](./framework-integrations/privy/sub-accounts) — Privy sub‑accounts |
| 51 | +- [Dynamic](./framework-integrations/nextjs-with-dynamic) — Dynamic integration |
| 52 | + |
| 53 | +### Reference (selected) |
| 54 | +- [SDK: createBaseAccount](./reference/core/createBaseAccount) |
| 55 | +- [SDK: getProvider](./reference/core/getProvider) |
| 56 | +- [Provider RPC Methods](./reference/core/provider-rpc-methods/request-overview) |
| 57 | +- [Capabilities](./reference/core/capabilities/overview) |
| 58 | +- [UI Elements](./reference/ui-elements/brand-guidelines) |
| 59 | +- [Onchain Contracts](./reference/onchain-contracts/smart-wallet) |
| 60 | + |
| 61 | +### More |
| 62 | +- [Troubleshooting](./more/troubleshooting/usage-details/popups) |
| 63 | +- [Base Gasless Campaign](./more/base-gasless-campaign) |
| 64 | +- [Telemetry](./more/telemetry) |
| 65 | +- [Migration Guide](./guides/migration-guide) |
| 66 | + |
| 67 | +### Basenames |
| 68 | +- [FAQ](./basenames/basenames-faq) |
| 69 | +- [Transfer](./basenames/basename-transfer) |
| 70 | +- [OnchainKit Tutorial](./basenames/basenames-onchainkit-tutorial) |
| 71 | +- [Wagmi Tutorial](./basenames/basenames-wagmi-tutorial) |
| 72 | + |
| 73 | +### Contribute |
| 74 | +- [Contribute](./contribute/contribute-to-base-account-docs) |
| 75 | +- [Security + Bug Bounty](./contribute/security-and-bug-bounty) |
| 76 | + |
| 77 | + |
| 78 | +## Quickstart (excerpts) |
| 79 | + |
| 80 | +Source: `https://docs.base.org/base-account/quickstart/web` |
| 81 | + |
| 82 | +Base Account lets you add a passkey‑secured ERC‑4337 smart account to your app, with sponsored gas, batch transactions, spend permissions, and sub‑accounts. |
| 83 | + |
| 84 | +Install and initialize: |
| 85 | + |
| 86 | +```bash |
| 87 | +npm install @base-org/account |
| 88 | +``` |
| 89 | + |
| 90 | +```ts |
| 91 | +import { createBaseAccount } from '@base-org/account' |
| 92 | + |
| 93 | +const account = await createBaseAccount({ |
| 94 | + owner: '0xYourEOA', |
| 95 | + chain: 'base-sepolia' |
| 96 | +}) |
| 97 | +``` |
| 98 | + |
| 99 | +Send a payment with Base Pay (testnet): |
| 100 | + |
| 101 | +```ts |
| 102 | +import { pay, getPaymentStatus } from '@base-org/account' |
| 103 | + |
| 104 | +const { id } = await pay({ amount: '5.00', to: '0xRecipient', testnet: true }) |
| 105 | +const { status } = await getPaymentStatus({ id }) |
| 106 | +``` |
| 107 | + |
| 108 | +Batch two calls in one user operation: |
| 109 | + |
| 110 | +```ts |
| 111 | +const result = await account.provider.request({ |
| 112 | + method: 'wallet_sendCalls', |
| 113 | + params: [{ |
| 114 | + calls: [ |
| 115 | + { to: USDC, data: erc20.approve(SPENDER, AMOUNT) }, |
| 116 | + { to: MERCHANT, data: erc20.transfer(MERCHANT, AMOUNT) } |
| 117 | + ] |
| 118 | + }] |
| 119 | +}) |
| 120 | +``` |
| 121 | + |
| 122 | +Expected result: a single ERC‑4337 userOp executes both calls atomically. Combine with a paymaster to sponsor user gas. |
| 123 | + |
| 124 | +Additional sources: |
| 125 | +- `https://docs.base.org/base-account/quickstart/mobile-integration` |
| 126 | +- `https://docs.base.org/base-account/framework-integrations/wagmi/setup` |
| 127 | + |
| 128 | + |
| 129 | +## Key Concepts (excerpts) |
| 130 | + |
| 131 | +Source: `https://docs.base.org/base-account/overview/what-is-base-account` |
| 132 | + |
| 133 | +- Ownership model: A Base Account is owned by an EOA or another smart wallet. Ownership can be rotated via recovery flows, and sub‑accounts can be created for app‑scoped spend. |
| 134 | +- Recovery: Supports social/device delegates with threshold approval. Ownership only changes after quorum is met and verification passes. |
| 135 | +- Nonces and batching: User operations increment nonces. Use batching to execute multi‑step flows in one atomic op and improve UX. |
| 136 | +- Gas abstraction: Integrate a paymaster to sponsor gas, including ERC‑20‑denominated gas, for gasless user experiences. |
| 137 | +- Spend permissions: Grant revocable, scoped allowances for specific contracts, functions, or limits to reduce approve‑forever risk. |
| 138 | +- Sub‑accounts: Create scoped accounts for apps/contexts to contain risk and simplify accounting. |
| 139 | +- Security assumptions: Only configured owner(s) can authorize changes. Recovery requires meeting your policy’s threshold. |
| 140 | + |
| 141 | +Additional sources: |
| 142 | +- `https://docs.base.org/base-account/overview/architecture` |
| 143 | +- `https://docs.base.org/base-account/improve-ux/spend-permissions` |
| 144 | +- `https://docs.base.org/base-account/improve-ux/sponsor-gas/paymasters` |
| 145 | +- `https://docs.base.org/base-account/improve-ux/batch-transactions` |
| 146 | + |
| 147 | + |
| 148 | +## API Reference (selected, pruned) |
| 149 | + |
| 150 | +Provider RPC methods (subset) |
| 151 | + |
| 152 | +- `wallet_sendCalls(params)` — Execute one or more calls in a single ERC‑4337 user operation. Returns a user operation hash. |
| 153 | + - Source: `https://docs.base.org/base-account/reference/core/provider-rpc-methods/wallet_sendCalls` |
| 154 | +- `wallet_getCapabilities()` — Return wallet features and limits supported by the provider. |
| 155 | + - Source: `https://docs.base.org/base-account/reference/core/provider-rpc-methods/request-overview` |
| 156 | + |
| 157 | +SDK helpers (subset) |
| 158 | + |
| 159 | +- `createBaseAccount(options)` — Initialize SDK and get a configured provider and helpers |
| 160 | + - Source: `https://docs.base.org/base-account/reference/core/createBaseAccount` |
| 161 | +- `getProvider()` — Access the EIP‑1193 provider wired to Base Account |
| 162 | + - Source: `https://docs.base.org/base-account/reference/core/getProvider` |
| 163 | +- `createSubAccount({ label })` — Create an app‑scoped sub‑account |
| 164 | + - Source: `https://docs.base.org/base-account/reference/core/capabilities/overview` |
| 165 | +- `pay({ amount, to, testnet })` and `getPaymentStatus({ id })` — Base Pay helpers for USDC flows |
| 166 | + - Source: `https://docs.base.org/base-account/guides/accept-payments` |
| 167 | + |
| 168 | +Minimal request example for `wallet_sendCalls`: |
| 169 | + |
| 170 | +```json |
| 171 | +{ |
| 172 | + "method": "wallet_sendCalls", |
| 173 | + "params": [ |
| 174 | + { |
| 175 | + "calls": [ |
| 176 | + { "to": "0xA0b8...USDC", "data": "0x095ea7b3..." }, |
| 177 | + { "to": "0xMerchant", "data": "0xa9059cbb..." } |
| 178 | + ], |
| 179 | + "sponsor": { "type": "paymaster" } |
| 180 | + } |
| 181 | + ] |
| 182 | +} |
| 183 | +``` |
| 184 | + |
| 185 | + |
| 186 | +## Examples (common flows) |
| 187 | + |
| 188 | +Example: Authenticate user with SIWE + ERC‑6492 |
| 189 | + |
| 190 | +Source: `https://docs.base.org/base-account/guides/authenticate-users` |
| 191 | + |
| 192 | +```ts |
| 193 | +// Sign‑in with Ethereum using a 6492‑compatible signature |
| 194 | +const message = createSiweMessage({ domain, address, statement, uri, version: '1', chainId }) |
| 195 | +const signature = await provider.request({ method: 'personal_sign', params: [message, address] }) |
| 196 | +// Verify server‑side with 6492 envelope support |
| 197 | +``` |
| 198 | + |
| 199 | +Example: USDC checkout with paymaster sponsorship |
| 200 | + |
| 201 | +Sources: |
| 202 | +- `https://docs.base.org/base-account/guides/accept-payments` |
| 203 | +- `https://docs.base.org/base-account/improve-ux/sponsor-gas/paymasters` |
| 204 | + |
| 205 | +```ts |
| 206 | +await provider.request({ |
| 207 | + method: 'wallet_sendCalls', |
| 208 | + params: [{ |
| 209 | + calls: [ |
| 210 | + { to: USDC, data: erc20.approve(MERCHANT, AMOUNT) }, |
| 211 | + { to: MERCHANT, data: erc20.transfer(MERCHANT, AMOUNT) } |
| 212 | + ], |
| 213 | + sponsor: { type: 'paymaster', token: 'USDC' } |
| 214 | + }] |
| 215 | +}) |
| 216 | +``` |
| 217 | + |
| 218 | +Example: Create and use a sub‑account for scoped spend |
| 219 | + |
| 220 | +Source: `https://docs.base.org/base-account/improve-ux/sub-accounts` |
| 221 | + |
| 222 | +```ts |
| 223 | +const sub = await account.createSubAccount({ label: 'checkout' }) |
| 224 | +await sub.provider.request({ method: 'wallet_sendCalls', params: [{ calls: [{ to: MERCHANT, data: data }] }] }) |
| 225 | +``` |
| 226 | + |
0 commit comments