diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 000000000..8c1ba9a22 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,91 @@ +# Base Docs Index +IMPORTANT: Prefer retrieval-led reasoning. Read relevant docs before generating code. +Base is an Ethereum L2 by Coinbase. Docs for: Base Chain, Smart Wallet, OnchainKit, MiniKit. +[Docs]|root:./docs +|ai-agents:index,trading +|ai-agents/core-concepts:agent-apps,agent-frameworks,identity-verification-auth,payments-and-transactions,wallets +|base-account/basenames:basename-transfer,basenames-faq,basenames-onchainkit-tutorial,basenames-wagmi-tutorial +|base-account/contribute:contribute-to-base-account-docs,security-and-bug-bounty +|base-account/framework-integrations:cdp,rainbowkit,reown,thirdweb +|base-account/framework-integrations/privy:authentication,setup,spend-permissions,sub-accounts,wallet-actions +|base-account/framework-integrations/wagmi:base-pay,basenames,batch-transactions,other-use-cases,setup,sign-in-with-base,sub-accounts +|base-account/guides:accept-payments,accept-recurring-payments,authenticate-users,migration-guide,sign-and-verify-typed-data +|base-account/guides/tips:inspect-txn-simulation,popup-tips +|base-account/improve-ux:batch-transactions,magic-spend,spend-permissions,sub-accounts +|base-account/improve-ux/sponsor-gas:erc20-paymasters,paymasters +|base-account/more:base-gasless-campaign,telemetry +|base-account/more/troubleshooting/usage-details:gas-usage,popups,simulations,unsupported-calls,wallet-library-support +|base-account/overview:what-is-base-account +|base-account/quickstart:ai-tools-available-for-devs,mobile-integration,web-react,web +|base-account/reference/base-pay:charge,getOrCreateSubscriptionOwnerWallet,getPaymentStatus,getStatus,pay,prepareCharge,prepareRevoke,revoke,subscribe,subscriptions-overview +|base-account/reference/core:createBaseAccount,generateKeyPair,getCryptoKeyAccount,getKeypair,getProvider,sdk-utilities +|base-account/reference/core/capabilities:atomic,auxiliaryFunds,dataSuffix,datacallback,flowControl,overview,paymasterService,signInWithEthereum +|base-account/reference/core/provider-rpc-methods:coinbase_fetchPermission,coinbase_fetchPermissions,eth_accounts,eth_blockNumber,eth_chainId,eth_coinbase,eth_estimateGas,eth_feeHistory,eth_gasPrice,eth_getBalance,eth_getBlockByHash,eth_getBlockByNumber,eth_getBlockTransactionCountByHash,eth_getBlockTransactionCountByNumber,eth_getCode,eth_getLogs,eth_getProof,eth_getStorageAt,eth_getTransactionByBlockHashAndIndex,eth_getTransactionByBlockNumberAndIndex,eth_getTransactionByHash,eth_getTransactionCount,eth_getTransactionReceipt,eth_getUncleCountByBlockHash,eth_getUncleCountByBlockNumber,eth_requestAccounts,eth_sendRawTransaction,eth_sendTransaction,eth_signTypedData_v4,personal_sign,request-overview,sdk-overview,standard-rpc-methods,wallet_addEthereumChain,wallet_addSubAccount,wallet_connect,wallet_getCallsStatus,wallet_getCapabilities,wallet_getSubAccounts,wallet_sendCalls,wallet_switchEthereumChain,wallet_watchAsset,web3_clientVersion +|base-account/reference/onchain-contracts:basenames,smart-wallet,spend-permissions +|base-account/reference/prolink-utilities:createProlinkUrl,decodeProlink,encodeProlink +|base-account/reference/spend-permission-utilities:fetchPermission,fetchPermissions,getPermissionStatus,prepareRevokeCallData,prepareSpendCallData,requestRevoke,requestSpendPermission +|base-account/reference/ui-elements:base-pay-button,brand-guidelines,sign-in-with-base-button +|base-chain/builder-codes:app-developers,bridge-developers,builder-codes,wallet-developers +|base-chain/flashblocks:api-reference,apps,docs,node-providers +|base-chain/network-information:base-contracts,block-building,bridges,configuration-changelog,diffs-ethereum-base,ecosystem-contracts,network-fees,transaction-finality,troubleshooting-transactions +|base-chain/node-operators:performance-tuning,run-a-base-node,snapshots,troubleshooting +|base-chain/quickstart:base-solana-bridge,connecting-to-base,deploy-on-base,why-base +|base-chain/reference:json-rpc-api +|base-chain/security:avoid-malicious-flags,bug-bounty,report-vulnerability,security-council +|base-chain/tools:account-abstraction,base-products,block-explorers,cross-chain,data-indexers,network-faucets,node-providers,onboarding,onchain-registry-api,onramps,oracles,tokens-in-wallet +|get-started:base-mentorship-program,base-services-hub,base,build-app,concepts,country-leads-and-ambassadors,deploy-smart-contracts,docs-llms,docs-mcp,get-funded,launch-token,learning-resources,prompt-library +|mini-apps/core-concepts:authentication,base-account,context,embeds-and-previews,manifest,navigation,notifications +|mini-apps/featured-guidelines:design-guidelines,notification-guidelines,overview,product-guidelines,technical-guidelines +|mini-apps/growth:build-viral-mini-apps,optimize-onboarding,rewards +|mini-apps/introduction:overview +|mini-apps/quality-and-publishing:overview,quality-bar,submission-guidelines +|mini-apps/quickstart:build-checklist,building-for-the-base-app,create-new-miniapp,migrate-existing-apps,template +|mini-apps/resources:design-resources,templates +|mini-apps/technical-guides:accept-payments,building-chat-agents,dynamic-embeds,neynar-notifications,sharing-and-social-graph,sign-manifest +|mini-apps/troubleshooting:base-app-compatibility,common-issues,error-handling,how-search-works,testing +|onchainkit:create-a-basename-profile-component,getting-started,installation,restricted,use-coinbase-smart-wallet-and-eoas +|onchainkit/api:build-deposit-to-morpho-tx,build-mint-transaction,build-swap-transaction,build-withdraw-from-morpho-tx,get-mint-details,get-portfolios,get-swap-quote,get-token-details,get-tokens,types +|onchainkit/buy:buy,types +|onchainkit/checkout:checkout,types +|onchainkit/config:is-base,is-ethereum,onchainkit-provider,supplemental-providers,types +|onchainkit/earn:earn,types +|onchainkit/fund:fetch-onramp-config,fetch-onramp-options,fetch-onramp-quote,fetch-onramp-transaction-status,fund-button,fund-card,get-onramp-buy-url,setup-onramp-event-listeners,types +|onchainkit/guides:ai-prompting-guide,build-onchain-apps,contribution,lifecycle-status,reporting-bug,tailwind,telemetry,themes,troubleshooting,use-basename-in-onchain-app,using-ai-powered-ides +|onchainkit/hooks:use-build-deposit-to-morpho-tx,use-build-withdraw-from-morpho-tx,use-earn-context,use-mint-details,use-morpho-vault,use-token-details +|onchainkit/identity:address,avatar,badge,get-address,get-attestations,get-avatar,get-avatars,get-name,get-names,identity-card,identity,name,socials,types,use-address,use-avatar,use-avatars,use-name,use-names +|onchainkit/installation:astro,nextjs,remix,vite +|onchainkit/latest/components/appchain:bridge +|onchainkit/latest/components/buy:buy +|onchainkit/latest/components/checkout:checkout +|onchainkit/latest/components/connected:connected +|onchainkit/latest/components/earn:earn +|onchainkit/latest/components/fund:fund-button,fund-card +|onchainkit/latest/components/identity:address,avatar,badge,identity-card,identity,name,socials +|onchainkit/latest/components/minikit:overview,provider-and-initialization +|onchainkit/latest/components/minikit/hooks:useAddFrame,useAuthenticate,useClose,useComposeCast,useMiniKit,useNotification,useOpenUrl,usePrimaryButton,useViewCast,useViewProfile +|onchainkit/latest/components/mint:nft-card,nft-mint-card +|onchainkit/latest/components/signature:signature +|onchainkit/latest/components/swap:swap-settings,swap +|onchainkit/latest/components/token:token-chip,token-image,token-row,token-search,token-select-dropdown +|onchainkit/latest/components/transaction:transaction +|onchainkit/latest/components/wallet:wallet-dropdown-basename,wallet-dropdown-disconnect,wallet-dropdown-fund-link,wallet-dropdown-link,wallet-island,wallet-modal,wallet +|onchainkit/latest/configuration:onchainkit-provider,themes,wagmi-viem-integration +|onchainkit/latest/getting-started:manual-installation,overview,quickstart-guide,troubleshooting +|onchainkit/latest/guides:ai-prompting-guide,contributing +|onchainkit/latest/hooks/earn:use-build-deposit-to-morpho-tx,use-build-withdraw-from-morpho-tx,use-earn-context,use-morpho-vault +|onchainkit/latest/hooks/identity:use-address,use-avatar,use-avatars,use-name,use-names +|onchainkit/latest/hooks/mint:use-mint-details,use-token-details +|onchainkit/latest/utilities/earn:build-deposit-to-morpho-tx,build-withdraw-from-morpho-tx +|onchainkit/latest/utilities/fund:fetch-onramp-config,fetch-onramp-options,fetch-onramp-quote,fetch-onramp-transaction-status,get-onramp-buy-url,setup-onramp-event-listeners +|onchainkit/latest/utilities/identity:get-address,get-attestations,get-avatar,get-avatars,get-name,get-names +|onchainkit/latest/utilities/token:format-amount +|onchainkit/latest/utilities/wallet:is-valid-aa-entrypoint,is-wallet-a-coinbase-smart-wallet +|onchainkit/mint:nft-card,nft-mint-card,types +|onchainkit/paymaster:erc20-paymaster,errors,gasless-transactions-with-paymaster,how-to-contribute,quickstart-guide,quickstart-headless,security,troubleshooting,welcome +|onchainkit/signature:signature,types +|onchainkit/swap:swap-settings,swap,types +|onchainkit/templates:onchain-commerce-app,onchain-nft-app,onchain-social-profile +|onchainkit/token:format-amount,token-chip,token-image,token-row,token-search,token-select-dropdown,types +|onchainkit/transaction:transaction,types +|onchainkit/wallet:is-valid-aa-entrypoint,is-wallet-a-coinbase-smart-wallet,types,wallet-dropdown-basename,wallet-dropdown-disconnect,wallet-dropdown-fund-link,wallet-dropdown-link,wallet-island,wallet-modal,wallet +|root:AGENTS,cookie-policy,privacy-policy,terms-of-service,tone_of_voice diff --git a/docs/AGENTS.md b/docs/AGENTS.md index 7c326864e..4aabd3728 100644 --- a/docs/AGENTS.md +++ b/docs/AGENTS.md @@ -32,8 +32,6 @@ Base is an Ethereum L2 by Coinbase. Docs for: Base Chain, Smart Wallet, OnchainK |base-chain/quickstart:base-solana-bridge,bridge-token,connecting-to-base,deploy-on-base,why-base |base-chain/security:avoid-malicious-flags,bug-bounty,report-vulnerability,security-council |base-chain/tools:account-abstraction,base-products,block-explorers,cross-chain,data-indexers,network-faucets,node-providers,onboarding,onchain-registry-api,onramps,oracles,tokens-in-wallet -|cookbook:accept-crypto-payments,ai-assisted-documentation-reading,ai-powered-development-fundamentals,ai-prompting,base-app-coins,base-builder-mcp,converting-customizing-mini-apps,defi-your-app,essential-documentation-resources,go-gasless,introduction-to-mini-apps,launch-ai-agents,launch-tokens,mastering-ai-prompt-engineering,onboard-any-user,onchain-social,spend-permissions-ai-agent,successful-miniapps-in-tba,testing-onchain-apps -|cookbook/minikit:add-frame-metadata,add-minikit,build-your-mini-app-with-prompt,configure-environment,create-manifest,fork-and-customize,install,manifest-cli,test-and-deploy |get-started:base-mentorship-program,base-services-hub,base,build-app,concepts,country-leads-and-ambassadors,deploy-smart-contracts,docs-llms,docs-mcp,get-funded,launch-token,prompt-library |learn:exercise-contracts,welcome |learn/address-and-payable:address-and-payable diff --git a/docs/ai-agents/llms-full.txt b/docs/ai-agents/llms-full.txt new file mode 100644 index 000000000..a0122bcac --- /dev/null +++ b/docs/ai-agents/llms-full.txt @@ -0,0 +1,98 @@ +# https://docs.base.org/ai-agents/llms-full.txt + +## AI Agents — Deep Guide for LLMs + +> Build AI agents that operate as independent economic actors on Base: a wallet to hold and spend funds, identity standards so other agents can trust it, a payment protocol for pay-per-request APIs, and a discovery layer so agents can find each other. + +### What you can do here +- Choose a framework (Agent SDK, OpenClaw, BANKR) to build and run your agent +- Give your agent a wallet to hold stablecoins and sign transactions +- Enable your agent to pay for services automatically using the x402 protocol +- Register and verify agent identity for agent-to-agent trust +- Build agent apps — services designed for agents as the primary user +- Apply Base-specific patterns for trading agents using Flashblocks + +## Navigation (with brief descriptions) + +### Introduction +- [AI Agents on Base](https://docs.base.org/ai-agents/index.md) — Overview and how pieces fit together + +### Core Concepts +- [Frameworks](https://docs.base.org/ai-agents/core-concepts/agent-frameworks.md) — Agent SDK, OpenClaw, BANKR comparison +- [Wallets](https://docs.base.org/ai-agents/core-concepts/wallets.md) — Wallet options and setup +- [Payments & Transactions](https://docs.base.org/ai-agents/core-concepts/payments-and-transactions.md) — x402 and skills +- [Identity, Verification & Auth](https://docs.base.org/ai-agents/core-concepts/identity-verification-auth.md) — Agent identity and trust +- [Agent Apps](https://docs.base.org/ai-agents/core-concepts/agent-apps.md) — Build agent-first services + +### Advanced +- [Trading on Base](https://docs.base.org/ai-agents/trading.md) — Flashblocks, fee calibration, trading signals + + +## Key Concepts (excerpts) + +Source: `https://docs.base.org/ai-agents/index.md` + +Base gives your AI agent the tools to operate as an independent economic actor: +- **Framework**: Self-hosted SDK, open-source assistant (OpenClaw), or managed API (BANKR) +- **Wallet**: Hold stablecoins, send payments, and sign transactions onchain +- **Payments**: Pay for API access with stablecoins using the x402 pay-per-request protocol +- **Identity**: Register your agent in a public directory so other agents and services can discover and verify it +- **Agent Apps**: Create services designed for agents, exposing structured endpoints agents can call programmatically + +Source: `https://docs.base.org/ai-agents/core-concepts/agent-frameworks.md` + +Framework comparison: +- **BANKR** — Managed Agent API with skill and wallet plugins; best for fast deployment +- **OpenClaw** — Open-source personal AI assistant (Discord, Telegram, web); best for multi-channel agents +- **Agent SDK** — Developer toolkit for custom agents with full control over behavior and integrations + +Source: `https://docs.base.org/ai-agents/core-concepts/wallets.md` + +An onchain wallet gives your agent the ability to hold funds, authorize transactions, and sign messages. Without one, your agent can read data but can't pay for services, receive payments, or prove its identity. + +Source: `https://docs.base.org/ai-agents/core-concepts/payments-and-transactions.md` + +- **x402 protocol**: Agents pay for services automatically with stablecoins on a per-request basis, no human approval required +- **Skills**: Pre-built onchain actions (swaps, transfers, contract calls) that your agent can perform through a structured API + +Source: `https://docs.base.org/ai-agents/core-concepts/identity-verification-auth.md` + +- Agents register in a public directory with verifiable credentials +- Other agents and services can look up and verify identity before trusting +- Authentication flows designed for machine-to-machine (no human in the loop) + +Source: `https://docs.base.org/ai-agents/core-concepts/agent-apps.md` + +- Agent apps expose structured endpoints (not visual UIs) that agents can discover and call +- Make your service discoverable by registering it in the agent directory +- Design APIs with explicit schemas so agents can reason about inputs and outputs + + +## Trading Agents (excerpts) + +Source: `https://docs.base.org/ai-agents/trading.md` + +Base offers two structural advantages for trading agents: +- **Flashblocks**: 200ms preconfirmed block state, 10× faster than the 2-second block +- **Exposed L1/L2 fee structure**: Enables explicit cost-vs-speed tradeoffs + +Key patterns: +- Connect to `mainnet-preconf.base.org` for all reads and submissions to access Flashblocks pending state +- Simulate with `eth_simulateV1` against preconfirmed state before signing any transaction +- Poll `base_transactionStatus` (not `eth_getTransactionReceipt`) for low-latency inclusion status (~200ms) +- Use `eth_feeHistory` over last 5–10 blocks with reward percentiles `[50, 90]` for fee calibration + +Fee calibration: +``` +maxFeePerGas = nextBaseFee * 2 + maxPriorityFeePerGas +``` + +L1 fee decision rule — if this ratio exceeds 0.8, L1 fee dominates; consider deferring small trades: +``` +l1FeeUpperBound / (gasLimit × maxFeePerGas + l1FeeUpperBound) > 0.8 +``` + +Key Flashblocks signals for trading: +- `eth_getBlockByNumber("pending")` on preconf endpoint — preconfirmed pending block state (200ms early) +- `eth_subscribe("newFlashblockTransactions")` — first-mover on large trades entering the block +- `eth_subscribe("pendingLogs", { address, topics })` — detect liquidation thresholds and oracle updates before finality diff --git a/docs/ai-agents/llms.txt b/docs/ai-agents/llms.txt new file mode 100644 index 000000000..b74256d85 --- /dev/null +++ b/docs/ai-agents/llms.txt @@ -0,0 +1,19 @@ +# https://docs.base.org/ai-agents/llms.txt + +## AI Agents Documentation + +> Build AI agents that operate as independent economic actors on Base — with wallets, payments, identity, and agent-to-agent discovery built in. + +## Introduction +- [AI Agents on Base](https://docs.base.org/ai-agents/index.md) — What you can build and how the pieces fit together + +## Core Concepts +- [Frameworks](https://docs.base.org/ai-agents/core-concepts/agent-frameworks.md) — Choose between Agent SDK, OpenClaw, and BANKR +- [Wallets](https://docs.base.org/ai-agents/core-concepts/wallets.md) — Give your agent the ability to hold funds and sign transactions +- [Payments & Transactions](https://docs.base.org/ai-agents/core-concepts/payments-and-transactions.md) — Pay for services with x402 and execute onchain actions via skills +- [Identity, Verification & Auth](https://docs.base.org/ai-agents/core-concepts/identity-verification-auth.md) — Register, discover, and verify agents +- [Agent Apps](https://docs.base.org/ai-agents/core-concepts/agent-apps.md) — Build services with agents as the primary user + +## Advanced +- [Trading on Base](https://docs.base.org/ai-agents/trading.md) — Flashblocks patterns, fee calibration, and onchain signals for trading agents + diff --git a/docs/base-account/improve-ux/spend-permissions.mdx b/docs/base-account/improve-ux/spend-permissions.mdx index 2cfe719ce..26044cc4c 100644 --- a/docs/base-account/improve-ux/spend-permissions.mdx +++ b/docs/base-account/improve-ux/spend-permissions.mdx @@ -358,6 +358,4 @@ This example demonstrates how to combine Base Account's [Spend Permissions](/bas > Explore the complete implementation on GitHub - - -**Learn more:** [AI Agent with Spend Permissions](/cookbook/spend-permissions-ai-agent) \ No newline at end of file + \ No newline at end of file diff --git a/docs/base-account/llms-full.txt b/docs/base-account/llms-full.txt index f9bc96e45..f9a9bd05f 100644 --- a/docs/base-account/llms-full.txt +++ b/docs/base-account/llms-full.txt @@ -47,8 +47,13 @@ const { status } = await getPaymentStatus({ id }) - [Wagmi Base Pay](https://docs.base.org/base-account/framework-integrations/wagmi/base-pay.md) — Payments - [Wagmi Other Use Cases](https://docs.base.org/base-account/framework-integrations/wagmi/other-use-cases.md) — Patterns - [Privy Setup](https://docs.base.org/base-account/framework-integrations/privy/setup.md) — Privy +- [Privy Authentication](https://docs.base.org/base-account/framework-integrations/privy/authentication.md) — Privy auth - [Privy Sub‑Accounts](https://docs.base.org/base-account/framework-integrations/privy/sub-accounts.md) — Privy sub‑accounts -- [Dynamic](https://docs.base.org/base-account/framework-integrations/nextjs-with-dynamic.md) — Dynamic integration +- [Privy Spend Permissions](https://docs.base.org/base-account/framework-integrations/privy/spend-permissions.md) — Privy spend permissions +- [RainbowKit](https://docs.base.org/base-account/framework-integrations/rainbowkit.md) — RainbowKit integration +- [Reown](https://docs.base.org/base-account/framework-integrations/reown.md) — Reown integration +- [Thirdweb](https://docs.base.org/base-account/framework-integrations/thirdweb.md) — Thirdweb integration +- [CDP](https://docs.base.org/base-account/framework-integrations/cdp.md) — CDP integration ### Reference (selected) - [SDK: createBaseAccount](https://docs.base.org/base-account/reference/core/createBaseAccount.md) diff --git a/docs/base-account/llms.txt b/docs/base-account/llms.txt index 15409b8f2..a8646e527 100644 --- a/docs/base-account/llms.txt +++ b/docs/base-account/llms.txt @@ -14,10 +14,14 @@ ## Guides - [Authenticate Users](https://docs.base.org/base-account/guides/authenticate-users.md) — SIWE with ERC‑6492 signatures - [Accept Payments](https://docs.base.org/base-account/guides/accept-payments.md) — One‑tap USDC payments with Base Pay +- [Accept Recurring Payments](https://docs.base.org/base-account/guides/accept-recurring-payments.md) — Subscription payments with Base Pay ## Framework Integrations - [Wagmi: Setup](https://docs.base.org/base-account/framework-integrations/wagmi/setup.md) — Configure connectors and chains - [Privy: Setup](https://docs.base.org/base-account/framework-integrations/privy/setup.md) — Authentication + sub‑accounts +- [RainbowKit](https://docs.base.org/base-account/framework-integrations/rainbowkit.md) — RainbowKit integration +- [Reown](https://docs.base.org/base-account/framework-integrations/reown.md) — Reown integration +- [CDP](https://docs.base.org/base-account/framework-integrations/cdp.md) — CDP integration ## Reference - [Account SDK: createBaseAccount](https://docs.base.org/base-account/reference/core/createBaseAccount.md) — Initialize SDK and provider diff --git a/docs/base-chain/llms-full.txt b/docs/base-chain/llms-full.txt index 62d918261..21700bf9f 100644 --- a/docs/base-chain/llms-full.txt +++ b/docs/base-chain/llms-full.txt @@ -19,7 +19,7 @@ - [Why Base](https://docs.base.org/base-chain/quickstart/why-base.md) — Platform value prop - [Deploy on Base](https://docs.base.org/base-chain/quickstart/deploy-on-base.md) — Deploy contracts (Foundry) - [Connecting to Base](https://docs.base.org/base-chain/quickstart/connecting-to-base.md) — App connectivity -- [Bridge Token](https://docs.base.org/base-chain/quickstart/bridge-token.md) — Transfer assets to Base +- [Base-Solana Bridge](https://docs.base.org/base-chain/quickstart/base-solana-bridge.md) — Bridge between Base and Solana ### Network Information - [Base Contracts](https://docs.base.org/base-chain/network-information/base-contracts.md) — Canonical addresses @@ -27,12 +27,15 @@ - [Ecosystem Contracts](https://docs.base.org/base-chain/network-information/ecosystem-contracts.md) — Third‑party addresses - [Block Building](https://docs.base.org/base-chain/network-information/block-building.md) — Block production - [Diffs vs Ethereum](https://docs.base.org/base-chain/network-information/diffs-ethereum-base.md) — Differences from L1 -- [Bridges (Mainnet)](https://docs.base.org/base-chain/network-information/bridges-mainnet.md) — Bridges +- [Bridges](https://docs.base.org/base-chain/network-information/bridges.md) — Bridges +- [Transaction Finality](https://docs.base.org/base-chain/network-information/transaction-finality.md) — Finality model +- [Configuration Changelog](https://docs.base.org/base-chain/network-information/configuration-changelog.md) — Network config changes ### Flashblocks - [Apps](https://docs.base.org/base-chain/flashblocks/apps.md) — Apps using Flashblocks - [Node Providers](https://docs.base.org/base-chain/flashblocks/node-providers.md) — Infra providers - [Docs](https://docs.base.org/base-chain/flashblocks/docs.md) — Documentation +- [API Reference](https://docs.base.org/base-chain/flashblocks/api-reference.md) — Flashblocks API reference ### Node Operators - [Run a Base Node](https://docs.base.org/base-chain/node-operators/run-a-base-node.md) — Node setup @@ -54,10 +57,14 @@ - [Oracles](https://docs.base.org/base-chain/tools/oracles.md) — Oracle providers - [Tokens in Wallet](https://docs.base.org/base-chain/tools/tokens-in-wallet.md) — Token inclusion +### Reference +- [JSON-RPC API](https://docs.base.org/base-chain/reference/json-rpc-api.md) — Base JSON-RPC API reference + ### Security - [Security Council](https://docs.base.org/base-chain/security/security-council.md) — Security governance - [Avoid Malicious Flags](https://docs.base.org/base-chain/security/avoid-malicious-flags.md) — App‑blocklist - [Report a Vulnerability](https://docs.base.org/base-chain/security/report-vulnerability.md) — Reporting +- [Bug Bounty](https://docs.base.org/base-chain/security/bug-bounty.md) — Bug bounty program ## Quickstart (excerpts) @@ -95,7 +102,7 @@ Source: `https://docs.base.org/base-chain/network-information/diffs-ethereum-bas - Canonical contracts: Use published address lists for bridges, system contracts, and registry. - Source: `https://docs.base.org/base-chain/network-information/base-contracts.md` - Bridges: Official and third‑party bridge options for moving assets to/from Base. - - Source: `https://docs.base.org/base-chain/network-information/bridges-mainnet.md` + - Source: `https://docs.base.org/base-chain/network-information/bridges.md` ## APIs and Tooling (pruned) @@ -141,6 +148,7 @@ Sources: - `https://docs.base.org/base-chain/flashblocks/docs.md` - `https://docs.base.org/base-chain/flashblocks/apps.md` - `https://docs.base.org/base-chain/flashblocks/node-providers.md` +- `https://docs.base.org/base-chain/flashblocks/api-reference.md` - Overview: Flashblocks resources aggregate information for builders and infra partners who need reliable, low‑latency access patterns on Base. - Ecosystem: Review apps that make use of Flashblocks‑related infra and the node providers who support relevant capabilities. @@ -159,17 +167,6 @@ console.log('latencyMs', Date.now() - t0, 'number', block.number) ## Examples (common flows) -Example: Bridge a token to Base (conceptual) - -Source: `https://docs.base.org/base-chain/quickstart/bridge-token.md` - -```text -1) Visit the official bridge UI -2) Select network (Ethereum → Base) -3) Choose asset and amount -4) Review fees and confirm -``` - Example: Read a contract on Base with Viem Source: `https://docs.base.org/base-chain/quickstart/connecting-to-base.md` @@ -181,4 +178,3 @@ import { base } from 'viem/chains' const client = createPublicClient({ chain: base, transport: http() }) const totalSupply = await client.readContract({ address: USDC, abi, functionName: 'totalSupply' }) ``` - diff --git a/docs/base-chain/llms.txt b/docs/base-chain/llms.txt index 3d638f7e3..78e23c72d 100644 --- a/docs/base-chain/llms.txt +++ b/docs/base-chain/llms.txt @@ -7,14 +7,17 @@ ## Quickstart - [Deploy on Base](https://docs.base.org/base-chain/quickstart/deploy-on-base.md) — Set up Foundry, configure RPCs, and deploy your first contract - [Connecting to Base](https://docs.base.org/base-chain/quickstart/connecting-to-base.md) — Configure providers and clients to read/write on Base +- [Base-Solana Bridge](https://docs.base.org/base-chain/quickstart/base-solana-bridge.md) — Bridge assets between Base and Solana ## Network Information - [Network Fees](https://docs.base.org/base-chain/network-information/network-fees.md) — L2 execution and L1 data costs on Base - [Base Contracts](https://docs.base.org/base-chain/network-information/base-contracts.md) — Core contracts and addresses +- [Bridges](https://docs.base.org/base-chain/network-information/bridges.md) — Official and third-party bridge options ## Flashblocks - [FAQ](https://docs.base.org/base-chain/flashblocks/docs.md) — Frequently asked questions about Flashblocks - [Apps](https://docs.base.org/base-chain/flashblocks/apps.md) — How apps integrate with Flashblocks +- [API Reference](https://docs.base.org/base-chain/flashblocks/api-reference.md) — Flashblocks API reference ## Node Operators - [Run a Base Node](https://docs.base.org/base-chain/node-operators/run-a-base-node.md) — Setup and operations guide @@ -31,5 +34,5 @@ ## Optional - [Block Explorers](https://docs.base.org/base-chain/tools/block-explorers.md) — Inspect contracts and transactions on Base - [Ecosystem Contracts](https://docs.base.org/base-chain/network-information/ecosystem-contracts.md) — Common ecosystem contract addresses - +- [JSON-RPC API](https://docs.base.org/base-chain/reference/json-rpc-api.md) — Base JSON-RPC API reference diff --git a/docs/cookbook/accept-crypto-payments.mdx b/docs/cookbook/accept-crypto-payments.mdx deleted file mode 100644 index dd293311d..000000000 --- a/docs/cookbook/accept-crypto-payments.mdx +++ /dev/null @@ -1,394 +0,0 @@ ---- -title: 'Accept Crypto Payments with Coinbase Commerce & OnchainKit' -sidebarTitle: 'Accept Crypto Payments' -description: 'Learn how to integrate Coinbase Commerce payments into your application using OnchainKit to eliminate traditional fees and expand your global reach.' ---- - -Accepting crypto payments can help you **eliminate traditional credit card fees** and **avoid costly chargebacks**, giving you a faster, more global payment experience. In this guide, you'll learn how to quickly integrate Coinbase Commerce and OnchainKit to accept crypto payments for products or services in your application. - -## What You'll Build - -By the end of this guide, you'll have a fully functional checkout flow that: - -- Displays your product with an attractive interface -- Connects users' wallets securely -- Processes crypto payments through Coinbase Commerce -- Provides real-time payment status updates - - - - Remove traditional credit card processing fees and chargebacks - - - Accept payments from crypto users worldwide, 24/7 - - - Receive payments instantly with blockchain confirmation - - - Get started in minutes with OnchainKit components - - - -## Prerequisites - -Before you begin, ensure you have the following accounts and tools set up: - - - - [Sign up for Coinbase Commerce](https://beta.commerce.coinbase.com/sign-up) to accept cryptocurrency payments globally. - - - You'll need this to create products and manage payments. - - - - - [Create a CDP account](https://www.coinbase.com/cloud) to access OnchainKit APIs and services. - - - CDP provides the infrastructure for seamless crypto integrations. - - - - - [Set up Reown](https://cloud.reown.com/) (formerly WalletConnect) for secure wallet connections across devices and platforms. - - - -## Implementation Guide - - - - - First, you'll create a product in Coinbase Commerce that represents what you're selling. - - 1. **Log in** to your [Coinbase Commerce dashboard](https://beta.commerce.coinbase.com/) - 2. Navigate to the [product creation page](https://beta.commerce.coinbase.com/products) - 3. **Fill in your product details**: - - Product name (clear and descriptive) - - Description (what customers are buying) - - Price (in your preferred currency) - 4. Click **Create product** - 5. Once created, select **View product** and copy the **UUID** from the URL - - - ![Create product screenshot](/images/onchainkit-tutorials/pay-create-product-details.png) - - - - Save the product UUID immediately - you'll need it as an environment variable. The UUID appears in the product URL after creation. - - - - - - Clone the official OnchainKit app template to get started quickly with best practices already configured. - - - ```bash Bun - git clone https://github.com/coinbase/onchainkit-app-template.git - cd onchainkit-app-template - bun install - ``` - - ```bash npm - git clone https://github.com/coinbase/onchainkit-app-template.git - cd onchainkit-app-template - npm install - ``` - - ```bash Yarn - git clone https://github.com/coinbase/onchainkit-app-template.git - cd onchainkit-app-template - yarn install - ``` - - - - Verify the installation completed successfully by running `ls` to see the project files. - - - - - - Create your environment configuration with the required API keys and identifiers. - - In your project root, create or update your `.env.local` file: - - ```bash .env.local - # Coinbase Commerce Product ID (from Step 1) - NEXT_PUBLIC_PRODUCT_ID=your_product_uuid_here - - # Coinbase Developer Platform API Key - NEXT_PUBLIC_ONCHAINKIT_API_KEY=your_cdp_api_key_here - - # Reown (WalletConnect) Project ID - NEXT_PUBLIC_WC_PROJECT_ID=your_walletconnect_project_id_here - - # Disable Next.js telemetry (optional) - NEXT_TELEMETRY_DISABLED=1 - ``` - - - Never commit API keys to version control. Add `.env.local` to your `.gitignore` file. - - - - Use descriptive variable names and keep them organized with comments for team members. - - - - - - Set up Wagmi to prioritize smart wallets for better user experience. - - Update your Wagmi configuration file (typically `src/app/wagmi.ts`): - - ```typescript src/app/wagmi.ts - // ... existing Wagmi configuration - - // After your useMemo() hook, add: - coinbaseWallet.preference = 'smartWalletOnly'; - ``` - - - This configuration ensures users connect with smart wallets, which provide enhanced security and better UX. - - - - - - Configure the OnchainKit provider to connect with Base network and your CDP API key. - - Update `src/app/components/OnchainProviders.tsx`: - - ```typescript src/app/components/OnchainProviders.tsx - 'use client'; - import { OnchainKitProvider } from '@coinbase/onchainkit'; - import { RainbowKitProvider } from '@rainbow-me/rainbowkit'; - import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; - import type { ReactNode } from 'react'; - import { base } from 'viem/chains'; - import { WagmiProvider } from 'wagmi'; - import { useWagmiConfig } from '../wagmi'; - - type Props = { children: ReactNode }; - const queryClient = new QueryClient(); - - function OnchainProviders({ children }: Props) { - const wagmiConfig = useWagmiConfig(); - - return ( - - - - - {children} - - - - - ); - } - - export default OnchainProviders; - ``` - - Update your configuration file to handle environment variables properly: - - ```typescript Config.ts - export const NEXT_PUBLIC_URL = - process.env.NODE_ENV === 'development' - ? 'http://localhost:3000' - : 'https://your-app-domain.vercel.app'; // Replace with your actual domain - - export const NEXT_PUBLIC_CDP_API_KEY = - process.env.NEXT_PUBLIC_ONCHAINKIT_API_KEY; - - export const NEXT_PUBLIC_WC_PROJECT_ID = - process.env.NEXT_PUBLIC_WC_PROJECT_ID; - ``` - - - Using environment variables makes your app more secure and easier to deploy across different environments. - - - - - - Create an attractive payment interface that showcases your product and handles the checkout flow. - - Update your main page (`src/app/page.tsx`): - - ```typescript src/app/page.tsx - import { Checkout, CheckoutButton, CheckoutStatus } from '@coinbase/onchainkit/checkout'; - import Image from 'next/image'; - - const productId = process.env.NEXT_PUBLIC_PRODUCT_ID; - - export default function PaymentPage() { - return ( -
-
- {/* Product showcase section */} -
- - {/* Product image container */} -
-
- Product image -
-
- - {/* Product information */} -
-

Your Amazing Product

-

High-quality product with crypto payment support

-
- - {/* Payment section */} -
- {address ? ( - - - - - ) : ( - - )} -
-
-
-
- ); - } - ``` - - - Make sure to add your product image to the `public` folder and update the image path accordingly. - - - - The conditional rendering prevents errors when no wallet is connected, providing a smooth user experience. - -
- - - - Test your payment flow locally before deploying to production. - - **Local Testing:** - - - ```bash Bun - bun run dev - ``` - - ```bash npm - npm run dev - ``` - - ```bash Yarn - yarn dev - ``` - - - 1. **Visit** `http://localhost:3000` - 2. **Connect your wallet** using the wallet connection button - 3. **Test the checkout flow** with a small amount - 4. **Verify payment status** updates correctly - - - ![Final product screenshot](/images/onchainkit-tutorials/pay-final-product.png) - - - **Production Deployment:** - - 1. **Update your configuration** with production URLs - 2. **Deploy to your preferred platform** (Vercel, Netlify, etc.) - 3. **Test the live application** with real transactions - 4. **Monitor payment confirmations** in your Coinbase Commerce dashboard - - - Start with testnet transactions to ensure everything works before going live with mainnet. - - -
- -## Troubleshooting - - - - **Common solutions:** - - Ensure your WalletConnect project ID is correctly configured - - Check that your wallet extension is updated to the latest version - - Try connecting with a different wallet provider - - Clear your browser cache and cookies - - - - **Check these items:** - - Verify your product ID matches exactly with Coinbase Commerce - - Ensure your CDP API key has the necessary permissions - - Confirm the user has sufficient funds for the transaction - - Check network connectivity and blockchain status - - - - **Configuration checklist:** - - All required environment variables are set in `.env.local` - - No extra spaces or quotes around variable values - - File is in the project root directory - - Restart your development server after making changes - - - -## Next Steps - -Now that you have crypto payments working, consider these enhancements: - - - - Scale your setup to handle multiple products and services - - - Set up payment confirmation webhooks for automated processing - - - Track payment metrics and customer behavior - - - Accept payments on multiple blockchain networks - - - -## Conclusion - -Congratulations! You've successfully integrated Coinbase Commerce and OnchainKit into your application. Your users can now make crypto payments, giving you access to: - -✅ **Zero traditional payment fees and chargebacks** -✅ **Global customer reach with 24/7 payment processing** -✅ **Instant settlement with blockchain confirmation** -✅ **Enhanced security through smart wallet integration** - -**Ready to scale?** Consider expanding to multiple products, implementing automated fulfillment, or adding analytics to track your crypto payment performance. - - -Your application now supports the future of global payments. Happy building on Base! - diff --git a/docs/cookbook/ai-assisted-documentation-reading.mdx b/docs/cookbook/ai-assisted-documentation-reading.mdx deleted file mode 100644 index 39465b03c..000000000 --- a/docs/cookbook/ai-assisted-documentation-reading.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -title: AI-Assisted Documentation Reading -description: Develop strategies for using AI tools to understand complex technical documentation and troubleshoot development challenges ---- - -# Techniques for understanding documentation - -AI tools excel at breaking down complex technical content into understandable explanations and practical guidance tailored to your specific learning needs and project requirements. Below are three techniques that you can use to leverage AI to help you understand documentation. - -### Used tailored prompts - -The "Explain Like I'm a Vibe Coder" approach involves asking AI to simplify technical concepts while maintaining practical applicability. This technique is particularly effective for understanding blockchain concepts, API documentation, and complex development patterns. The key is providing context about your current knowledge level and specific goals rather than asking for generic explanations. - - -``` -I'm looking at this API documentation but finding it confusing. -I want to implement the `Checkout` component on the checkout.tsx page of my website. -Please explain this like I'm a Vibe Coder (someone new to blockchain development but familiar with basic web development): -``` - -```typescript Checkout.tsx -const chargeHandler = async () => { - const response = await fetch('/createCharge', { method: 'POST' }); - const { id } = await response.json(); - return id; // Return charge ID -}; - - - -; -``` - - - -### Use Screenshots - -Sharing a screenshot with AI enhances its ability to understand your problem significantly. When you encounter confusing documentation sections, interfaces, or error messages, including screenshots in your AI prompts provides visual context that pure text cannot convey. Most AI tools can analyze images and provide specific guidance based on what they observe in your screenshots. - - -``` -I'm looking at this API documentation but finding it confusing. I want to implement the `Checkout` component on the checkout.tsx page of my website. - -I have attached two screenshots. The first screenshot is the page I would like to implement the `Checkout` component on. The second screenshot is the API documentation I am looking at. - -Please explain this like I'm a Vibe Coder (someone new to blockchain development but familiar with basic web development): - -[Screenshot 1] - -[Screenshot 2] - -``` - - - -### Use code snippets - -Code snippet analysis is another powerful technique. When you find example code in documentation but don't understand how it applies to your situation, you can paste the code into an AI prompt along with your specific requirements. The AI can explain the code's purpose, modify it for your needs, and highlight potential issues or improvements. - - -``` - -I'm looking at this API documentation but finding it confusing. Please explain this like I'm a Vibe Coder (someone new to blockchain development but familiar with basic web development): - -[PASTE DOCUMENTATION SECTION HERE] - -Specifically help me understand: - -1. What this API does in simple terms -2. When I would use it in my Mini App -3. What the key parameters mean -4. A practical example with my specific use case: [DESCRIBE YOUR USE CASE] - -Break it down step-by-step and include a working code example I can copy and modify. - -``` - - -``` diff --git a/docs/cookbook/ai-powered-development-fundamentals.mdx b/docs/cookbook/ai-powered-development-fundamentals.mdx deleted file mode 100644 index 323989bbc..000000000 --- a/docs/cookbook/ai-powered-development-fundamentals.mdx +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: Vibe Coding Fundamentals -description: Combine traditional web development with AI-powered code generation ---- - -# Vibe Coding Mini Apps - -Mini Apps are just web apps—with added capabilities. If you've built a website, you're already halfway there. The difference is that Mini Apps are designed to work seamlessly inside social feeds, come with built-in wallets, and connect to open, onchain identity. - -The easiest way to get started is with MiniKit, a toolkit that gives you ready-to-go templates. These templates handle the heavy lifting—wallet integration, social feed support, and identity management—so you can focus on what your app actually does. - -You can also build using AI tools that turn ideas into code. Tools like [Vercel V0](https://v0.dev/), [Claude Code](https://www.anthropic.com/claude-code), and [Loveable](https://lovable.dev/) let you describe your app in plain language and generate working code in minutes. They're perfect for creators, vibe coders, and anyone who wants to build without spending weeks learning a new framework. - -In this guide, we'll use AI to help build a Mini App that also works as a standalone website. That means what you build can live on Base, show up in TBA, and still work on the open web. - -## Vibe Coding Elements - -Vibe coding is a powerful way to bring your idea to life especially for non-developers. - -Below are the elements that you will need to consider when vibe coding a mini app. - - - -Clarify the app's purpose, target audience, and core features. Decide on the minimum viable product (MVP) and ensure it's achievable within your available time and resources. - - - - Map out the user journey, key screens, and interactions. Choose the tech - stack, plan integrations (APIs, onchain features, etc.), and decide on the - app's overall architecture. - - - - Implement the primary functionality first, focusing on the MVP. Keep - components modular for easier testing and iteration. - - - - Run functional, performance, and user tests to catch bugs and improve the - experience. Incorporate feedback and make necessary adjustments. - - - -Deploy to your hosting platform (e.g., Vercel, Fleek). Share the app with your intended audience, gather real-world feedback, and iterate as needed. - - diff --git a/docs/cookbook/ai-prompting.mdx b/docs/cookbook/ai-prompting.mdx deleted file mode 100644 index 6c5725ec4..000000000 --- a/docs/cookbook/ai-prompting.mdx +++ /dev/null @@ -1,9 +0,0 @@ ---- -sidebarTitle: AI-powered IDEs -title: Use AI-powered IDEs -description: How to use AI-powered IDEs to generate code for OnchainKit. ---- - -import AiPowered from "/snippets/ai-powered.mdx"; - - diff --git a/docs/cookbook/base-app-coins.mdx b/docs/cookbook/base-app-coins.mdx deleted file mode 100644 index c52c5eb82..000000000 --- a/docs/cookbook/base-app-coins.mdx +++ /dev/null @@ -1,326 +0,0 @@ ---- -sidebarTitle: Base App Coins -title: 'Find and load metadata for all coins created via Base App' -description: 'Learn how to use onchain data to index all Uniswap v4 pools created for coins created via Zora and Base App and load metadata including available liquidity, current prices, token information, and more' ---- - -With the launch of Base App, users can post on the network and get paid by coining their content. The content coins are created via Zora and a Uniswap v4 pool is automatically created and initialized for the coin. In this starter guide we will cover how you can index onchain data from Uniswap to identify all pools containing Zora ecosystem tokens, filtering Base App tokens from them, and loading metadata for those pools. - -## Overview - -The full code for this starter implementation can be found [here](https://github.com/base/demos/tree/master/base-app-coins). The guide below explains the core components, how it works, and what parts you may need to customize to your needs. - -The sample is a Bun + TypeScript project that uses `viem` for interacting with Base Chain via standard Ethereum JSON-RPC methods. It also utilizes Uniswap's SDKs to make some calculations easier. - -## Core Components - -#### 1. Event Monitoring (`index.ts`) -The main entry point scans Uniswap V4 `Initialize` events within a specified block range to discover newly created pools. - -```typescript -const logs = await publicClient.getContractEvents({ - abi: UniswapV4ABI, - address: UniswapV4PoolManager, - fromBlock: START_BLOCK_NUMBER, - toBlock: END_BLOCK_NUMBER, - eventName: "Initialize" -}) - -const poolKeys = logs.map((log) => { - return { - currency0: log.args.currency0, - currency1: log.args.currency1, - fee: log.args.fee, - tickSpacing: log.args.tickSpacing, - hooks: log.args.hooks - } -}) as PoolKey[] -``` - -**Key aspects:** -- Uses `publicClient.getContractEvents()` to fetch pool initialization events -- Filters events from the Uniswap V4 PoolManager contract -- Extracts pool keys (currency0, currency1, fee, tickSpacing, hooks) from event logs - -**Customizations:** -- Adjust `START_BLOCK_NUMBER` and `END_BLOCK_NUMBER` for your needs -- If you'd like to index these events in real-time, use `viem`s `watchContractEvent` instead - - -#### 2. Pool Data Loading (`utils.ts`) -Contains utilities for enriching pool data with on-chain information. - -```typescript -export async function loadData(key: PoolKey) { - // Load information about each token (name, symbol, decimals) - const [currency0, currency1] = await Promise.all([ - getCurrency(key.currency0), - getCurrency(key.currency1) - ]) - - const poolId = Pool.getPoolId(currency0, currency1, key.fee, key.tickSpacing, key.hooks) as `0x${string}`; - // Load the current price of the pool - const [sqrtPriceX96, tick, _protocolFee, _lpFee] = await stateView.read.getSlot0([poolId]); - // Load the total amount of liquidity available in the pool - const liquidity = await stateView.read.getLiquidity([poolId]) - - // - const pool = new Pool( - currency0, - currency1, - key.fee, - key.tickSpacing, - key.hooks, - sqrtPriceX96.toString(), - liquidity.toString(), - tick, - ) - return pool; -} -``` - - -**Currency Resolution:** -```typescript -export async function getCurrency(address: string): Promise { - if (address === zeroAddress) { - return Ether.onChain(base.id); - } - - const erc20 = getContract({ - abi: erc20Abi, - address: address as `0x${string}`, - client: publicClient - }) - - const [name, symbol, decimals] = await Promise.all([ - erc20.read.name(), - erc20.read.symbol(), - erc20.read.decimals() - ]) - - return new Token(base.id, address, decimals, symbol, name) -} -``` - -**Technical details:** -- Uses Uniswap V4 StateView contract for efficient state queries -- Handles both ERC20 tokens and native ETH (zero address) - - -#### 3. Token Classification Logic - -```typescript -let coinType: string | undefined; -if (key.hooks === "0xd61A675F8a0c67A73DC3B54FB7318B4D91409040") { - coinType = "ZORA_CREATOR_COIN" -} else if (key.hooks === "0x9ea932730A7787000042e34390B8E435dD839040") { - coinType = "ZORA_V4_COIN" -} - -if (!coinType) continue; - -// Detect if the coin is coming from Base App or Zora -const appType = await categorizeAppType(pool); -``` - -**Base App Token Detection:** -```typescript - -export async function categorizeAppType(pool: Pool) { - async function tryGetPlatformReferrer(address: string) { - const zoraBaseCoin = getContract({ - abi: parseAbi([ - "function platformReferrer() view returns (address)", - ]), - address: address as `0x${string}`, - client: publicClient - }) - - try { - const platformReferrer = await zoraBaseCoin.read.platformReferrer() - return platformReferrer - } catch (error) { - return ADDRESS_ZERO - } - } - - // Try to fetch `platformReferrer()` on both currencies in the Pool - // falling back to ADDRESS_ZERO if the function does not exist (currency is not a Zora coin) - const [currency0PlatformReferrer, currency1PlatformReferrer] = await Promise.all([ - tryGetPlatformReferrer(pool.currency0.wrapped.address), - tryGetPlatformReferrer(pool.currency1.wrapped.address) - ]) - - // If either of the currencies has the Base App referrer address, - // the coin is coming from the Base App - if ([currency0PlatformReferrer, currency1PlatformReferrer].includes(BASE_PLATFORM_REFERRER)) { - return "TBA" - } - - return "ZORA" -} -``` - -Since the coins are created via Zora, filtering down to which ones are from Base App is a matter of looking at what the platform referrer address is on the Zora coin. We don't know if the Zora coin is necessarily `currency0` or `currency1` in the pool - so we attempt to fetch the platform referrer address for both. For tokens like WETH which don't have that view function available, it will just fall back to the zero address. If either of the currencies return a valid platform referrer address that also matches the referrer address used by the Base App, we classify the coin as having come from the Base App. - - -#### 4. Liquidity Calculations - -```typescript -const priceUpper = TickMath.getSqrtRatioAtTick(TickMath.MAX_TICK) -const priceLower = TickMath.getSqrtRatioAtTick(TickMath.MIN_TICK) - -const amount0 = SqrtPriceMath.getAmount0Delta(pool.sqrtRatioX96, priceUpper, pool.liquidity, true); -const amount1 = SqrtPriceMath.getAmount1Delta(priceLower, pool.sqrtRatioX96, pool.liquidity, true) - -const amount0HumanReadable = formatUnits(BigInt(amount0.toString()), pool.currency0.decimals); -const amount1HumanReadable = formatUnits(BigInt(amount1.toString()), pool.currency1.decimals); -``` - -Given the `liquidity` amount we loaded previously for a pool, we utilize Uniswap's SDK to do some math and get human-friendly versions of how much of each token is available in the pool as total liquidity. - - -## Alternative Implementation Approaches - -### Event Data Sources - -This implementation uses direct JSON-RPC calls via `viem`, but you can adapt it for other data sources: - -**Subgraphs**: If you're already using The Graph Protocol, modify the event fetching logic to query a Uniswap V4 subgraph instead of making direct RPC calls. Replace the `getContractEvents` call with GraphQL queries. - -**Indexing Services**: For projects using third-party indexing services with their own APIs, substitute their event APIs while maintaining the same pool key extraction logic. - -**Real-time Monitoring**: Convert from batch processing to real-time by setting up WebSocket subscriptions to new block events and processing pools as they're created. - -### Data Storage - -The current implementation prints metadata to console, but you might want to: -- Store results in a database for persistent analysis -- Send data to external APIs or webhooks -- Cache results to avoid re-processing known pools - -## Output - - -The output metadata object contains the following fields: - -```typescript -const metadata = { - id: pool.poolId, - key: pool.poolKey, - currency0: { - name: pool.currency0.name, - symbol: pool.currency0.symbol, - decimals: pool.currency0.decimals, - address: pool.currency0.wrapped.address, - }, - currency1: { - name: pool.currency1.name, - symbol: pool.currency1.symbol, - decimals: pool.currency1.decimals, - address: pool.currency1.wrapped.address, - }, - sqrtPriceX96: pool.sqrtRatioX96.toString(), - tick: pool.tickCurrent, - liquidity: pool.liquidity.toString(), - liquidityCurrency0: amount0.toString(), - liquidityCurrency1: amount1.toString(), - liquidityCurrency0HumanReadable: `${amount0HumanReadable} ${pool.currency0.symbol}`, - liquidityCurrency1HumanReadable: `${amount1HumanReadable} ${pool.currency1.symbol}`, - currency0Price, - currency1Price, - currency0PriceHumanReadable: `1 ${pool.currency0.symbol} = ${currency0Price} ${pool.currency1.symbol}`, - currency1PriceHumanReadable: `1 ${pool.currency1.symbol} = ${currency1Price} ${pool.currency0.symbol}`, - coinType, - appType -} -``` - -### Pool Identifiers -- `id`: Unique pool identifier hash -- `key`: Complete pool key object with currencies, fee, tickSpacing, and hooks - -### Currency Information -- `currency0/currency1.name`: Human-readable token name -- `currency0/currency1.symbol`: Token symbol (e.g., "USDC", "WETH") -- `currency0/currency1.decimals`: Token decimal places for formatting -- `currency0/currency1.address`: Contract address - -### Price Data -- `sqrtPriceX96`: Current pool price in Uniswap's sqrt format -- `tick`: Current tick (logarithmic price representation) -- `currency0Price`: Price of currency0 in terms of currency1 -- `currency1Price`: Price of currency1 in terms of currency0 -- `currency0PriceHumanReadable`: Formatted price string -- `currency1PriceHumanReadable`: Formatted price string - -### Liquidity Metrics -- `liquidity`: Total pool liquidity in Uniswap's internal format -- `liquidityCurrency0`: Amount of currency0 in the pool (raw) -- `liquidityCurrency1`: Amount of currency1 in the pool (raw) -- `liquidityCurrency0HumanReadable`: Formatted amount with symbol -- `liquidityCurrency1HumanReadable`: Formatted amount with symbol - -### Classification -- `coinType`: Type of Zora token ("ZORA_CREATOR_COIN" or "ZORA_V4_COIN") -- `appType`: Application ecosystem ("ZORA" or "TBA") - -## Use Cases for Metadata - -### Analytics & Monitoring -- **Price Tracking**: Monitor token prices and price movements over time -- **Liquidity Analysis**: Track total value locked (TVL) in various token pools -- **Market Discovery**: Identify new tokens entering the ecosystem - -### Trading & DeFi -- **Arbitrage Detection**: Compare prices across different pools or DEXs -- **Liquidity Provider Analysis**: Evaluate pool attractiveness for LP positions -- **Volume Analysis**: Track trading activity in specific token categories - -### Ecosystem Analysis -- **Token Categorization**: Understand which tokens belong to which ecosystems -- **Adoption Metrics**: Monitor growth of Zora and Base App token usage -- **Cross-chain Comparison**: Compare activity across different networks - -### Integration Projects -- **Portfolio Tracking**: Include Zora/Base App tokens in portfolio management apps -- **Wallet Integration**: Enhance wallet UIs with ecosystem-specific token information -- **DeFi Protocols**: Build lending, staking, or yield farming products around these tokens - -## Configuration - -### Environment Variables -- `RPC_URL`: Base chain RPC endpoint (required) - -### Block Range -Modify `START_BLOCK_NUMBER` and `END_BLOCK_NUMBER` in `index.ts` to scan different ranges or implement continuous monitoring. - -### Hook Addresses -Add new hook addresses to the classification logic as new Zora contracts are deployed. - -## Getting Started - -```bash -# Install dependencies -bun install - -# Set your RPC URL -export RPC_URL="your-base-rpc-endpoint" - -# Run the scanner -bun run index.ts -``` - -The output will display metadata for each discovered pool that matches the classification criteria. - -## Extensions & Modifications - -This starter guide can be extended in many ways: -- Add support for additional hook contracts as they're deployed -- Include historical price and volume data -- Add alerts for significant liquidity changes -- Build web interfaces for browsing discovered pools -- Integrate with portfolio tracking or trading applications - -The modular structure makes it easy to adapt individual components while maintaining the core pool discovery and classification logic. \ No newline at end of file diff --git a/docs/cookbook/base-builder-mcp.mdx b/docs/cookbook/base-builder-mcp.mdx deleted file mode 100644 index 04206c5fc..000000000 --- a/docs/cookbook/base-builder-mcp.mdx +++ /dev/null @@ -1,10 +0,0 @@ ---- -sidebarTitle: 'Prompt Library' -title: Developer's Guide to Effective AI Prompting -description: Learn practical AI prompting techniques to enhance your coding workflow and get better results from AI coding assistants. ---- - - -import AiPrompt from "/snippets/prompt-library.mdx"; - - diff --git a/docs/cookbook/converting-customizing-mini-apps.mdx b/docs/cookbook/converting-customizing-mini-apps.mdx deleted file mode 100644 index d3aebbd10..000000000 --- a/docs/cookbook/converting-customizing-mini-apps.mdx +++ /dev/null @@ -1,160 +0,0 @@ ---- -title: Make Your Web App a Mini App -description: Convert your downloaded frontend into a Mini App by integrating MiniKit, Smart Wallet, and Paymaster ---- - -# Add MiniKit to Your App - -You have a clean frontend. Now turn it into a Mini App. Vibe coding tools are great for UI, but they do not yet handle onchain pieces perfectly. Download your code, open it in Cursor or Claude Code, and add MiniKit to enable Smart Wallet, gasless transactions, and Base App integration. - - - Before you prompt your AI IDE, list where you want onchain interactions to - happen. Examples: mint a collectible from the Create screen, tip from the - Feed, swap on the Trade screen. This helps the AI place MiniKit components in - the right files. - - - - - Launch Cursor or Claude Code and open your Next.js project. Ensure it runs - locally first with npm run dev so the AI can follow a working - baseline. - - - Use the MiniKit existing-app integration page. Use the site dropdown to - “Copy page as Markdown for LLMs”, then paste that markdown into your AI IDE - as context. - - - Have the AI map your routes, layout, and component structure. Ask it to - propose exact integration points for MiniKit provider and hooks. - - - Add the MiniKit provider in app/layout.tsx (or your top-level - layout), wire basic hooks, and confirm no “login” button is added. Mini Apps - should feel native and sessionless. - - - Configure Coinbase Developer Platform Paymaster with environment variables. - Update your action flows to sponsor transactions, then test locally. - - - Run your app, test every onchain touchpoint, and commit changes with clear - messages. You are ready to deploy. - - - -## Helpful Prompts: - - - **Shortcut:** On any of the Base docs pages, use the dropdown to “Copy page as - Markdown for LLMs” and paste it directly into your AI chat. This gives the - model precise instructions and reduces hallucinations. - - - - -``` -Guide me through converting my existing web application into a Mini App: - -EXISTING APP ANALYSIS: - -My app is built with [DESCRIBE YOUR TECH STACK] - -Current features include: [LIST MAIN FEATURES] - -User authentication currently uses: [DESCRIBE AUTH METHOD] - -Data is stored using: [DESCRIBE DATA STORAGE] - -INTEGRATION REQUIREMENTS: - -Add MiniKit provider and Smart Wallet in app/layout.tsx - -Integrate Coinbase Paymaster for gasless transactions - -Place onchain actions on these screens: [LIST SCREENS] - -Configure env vars for Base and CDP - -Avoid adding any login button - -DEPLOYMENT CONFIGURATION: - -Prepare .env.local for local and Vercel for production - -Deploy with Vercel CLI - -Test Base App integration flows - -TROUBLESHOOTING SETUP: - -Log wallet and sponsorship states - -Add clear error toasts - -Provide rollbacks for provider or env misconfig - -Provide step-by-step instructions with exact code changes and file paths. Include troubleshooting tips for common conversion issues. -``` - - - - -Paste this into your AI IDE. Replace bracketed parts with your details. Include the MiniKit “existing app integration” markdown from docs.base.org as an additional message. - -``` -You are assisting me in converting a downloaded Next.js app into a Mini App for the Base App (TBA). - -ANALYZE THE PROJECT - -Inspect my Next.js structure (app/, components/, utils/) and identify the best integration points for: - -MiniKit provider in app/layout.tsx - -Smart Wallet setup - -Any hooks needed to access Base App context - -List every file you plan to modify and why. - -INTEGRATION REQUIREMENTS - -Use MiniKit as per the docs I will paste. - -Use Coinbase Developer Platform (CDP) Paymaster for gasless transactions. - -Use Smart Wallet. - -Do NOT create a login button. - -Keep the current routing and UI intact. - -ONCHAIN TOUCHPOINTS IN MY APP - -I want onchain interactions in these places: -[Describe screens and actions, e.g., Create screen: mint item; Feed: tip creator; Trade: swap token] - -IMPLEMENTATION PLAN - -Propose exact code changes with file paths and code blocks. - -- Add required env vars and tell me where to put them (.env.local). -- Update any server actions or API routes needed to call Paymaster safely. - -VALIDATION - -Provide a test checklist to verify: -- Provider mounts without errors -- Smart Wallet available - -Paymaster sponsoring a sample transaction - -No login button rendered - -Include troubleshooting tips for common issues (env vars, build errors, missing providers). - -Now request any files you need to see to proceed, and confirm assumptions before editing. -``` - - diff --git a/docs/cookbook/defi-your-app.mdx b/docs/cookbook/defi-your-app.mdx deleted file mode 100644 index 3d330fa65..000000000 --- a/docs/cookbook/defi-your-app.mdx +++ /dev/null @@ -1,326 +0,0 @@ ---- -title: Defi Your App -description: Add common financial features like token swaps and yield generating strategies to your app with pre-built React components from OnchainKit. ---- - -import { Danger } from "/snippets/danger.mdx"; - -When businesses and individuals make financial transactions, it often includes swapping assets and then storing eligible assets in a yield generating strategy. This guide will show you how to quickly add these features to your app with pre-built React components from OnchainKit. - -## Ready-to-use components -- [``](/onchainkit/swap/swap): Swap assets directly within your app. -- [``](/onchainkit/earn/earn): Generate yield directly within your app. -- [``](/onchainkit/fund/fund-card): Fund their wallets with fiat (via USDC, Apple Pay, or debit card) without leaving your appi -- [``](/onchainkit/buy/buy): Purchase tokens directly within your app. - - -By embedding the `Swap` and `Earn` components, your users don't need to leave your app to execute these common actions. For users who lack onchain funds, the `Fund` and `Buy` components offer an integrated fiat-to-crypto onramp. - - -## Swap Component Integration - -The `Swap` component lets users exchange one token for another directly in your application. It fetches live quotes, builds transactions, and executes swaps—abstracting the underlying complexity. - -Lets add the `Swap` component to your app. - - - - Create a new OnchainKit app - - ```bash Terminal - npm create onchain@latest - ``` - - - ```typescript App.tsx - import { SwapDefault } from '@coinbase/onchainkit/swap'; // [!code focus] - import type { Token } from '@coinbase/onchainkit/token'; - - const eth: Token = { - name: 'ETH', - address: '', - symbol: 'ETH', - decimals: 18, - image: - 'https://wallet-api-production.s3.amazonaws.com/uploads/tokens/eth_288.png', - chainId: 8453, - }; - - const usdc: Token = { - name: 'USDC', - address: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913', - symbol: 'USDC', - decimals: 6, - image: - 'https://d3r81g40ycuhqg.cloudfront.net/wallet/wais/44/2b/442b80bd16af0c0d9b22e03a16753823fe826e5bfd457292b55fa0ba8c1ba213-ZWUzYjJmZGUtMDYxNy00NDcyLTg0NjQtMWI4OGEwYjBiODE2', - chainId: 8453, - }; - - // [!code focus] - ``` - - - -You should now see the following swap component in your app: - -