Getting Started # https://docs.base.org/builderkits/onchainkit/llms.txt ## OnchainKit Documentation This file contains structured documentation for AI assistants about OnchainKit, OnchainKit streamlines app development by providing a comprehensive toolkit that combines powerful onchain features with developer-friendly design: Please refer to https://docs.base.org/llms-full.txt for the complete Base documentation. On this page Chevron Right OnchainKit is your go-to SDK for building beautiful onchain applications. Ship in minutes, not weeks. Anyone can build an onchain app in 15 minutes with OnchainKit. No blockchain experience required. ## Why OnchainKit? OnchainKit streamlines app development by providing a comprehensive toolkit that combines powerful onchain features with developer-friendly design: - **Ergonomic design:** Full-stack tools that make complex onchain interactions intuitive - **Battle-tested patterns:** Industry best practices packaged into ready-to-use solutions - **Purpose-built components:** Pre-built modules for common onchain workflows - **Framework agnostic:** Compatible with any React-supporting framework - **Supercharged by Base:** Deep integration with Base's protocol features and ecosystem ## Automatic Installation ![OnchainKit Template](https://docs.base.org/images/onchainkit/quickstart.png) We recommend starting a new OnchainKit app using `create onchain`, which sets up everything automatically for you. To create a project, run: Terminal Terminal ```vocs_Code Copynpm create onchain@latest ``` After the prompts, `create onchain` will create a folder with your project name and install the required dependencies. You can also checkout our pre-built templates: - [Onchain Commerce](https://onchain-commerce-template.vercel.app/) - [NFT minting](https://ock-mint.vercel.app/) - [Funding flow](https://github.com/fakepixels/fund-component) - [Social profile](https://github.com/fakepixels/ock-identity) ## Manual Installation Add OnchainKit to your existing project manually. [Next.js\\ \\ Next.js](https://docs.base.org/builderkits/onchainkit/installation/nextjs) [Vite\\ \\ Vite](https://docs.base.org/builderkits/onchainkit/installation/vite) [Remix\\ \\ Remix](https://docs.base.org/builderkits/onchainkit/installation/remix) [Astro\\ \\ Astro](https://docs.base.org/builderkits/onchainkit/installation/astro) # Start building! Explore our ready-to-use onchain components: - [**`Identity`**](https://docs.base.org/builderkits/onchainkit/identity/identity)\- Show [Basenames](https://docs.base.org/builderkits/onchainkit/identity/identity), [avatars](https://docs.base.org/builderkits/onchainkit/identity/avatar), [badges](https://docs.base.org/builderkits/onchainkit/identity/badge), and [addresses](https://docs.base.org/builderkits/onchainkit/identity/address). - [**`Wallet`**](https://docs.base.org/builderkits/onchainkit/wallet/wallet)\- Create or connect wallets with [Connect Wallet](https://docs.base.org/builderkits/onchainkit/wallet/wallet). - [**`Transaction`**](https://docs.base.org/builderkits/onchainkit/transaction/transaction)\- Handle [transactions](https://docs.base.org/builderkits/onchainkit/transaction/transaction) using EOAs or Smart Wallets. - [**`Checkout`**](https://docs.base.org/builderkits/onchainkit/checkout/checkout)\- Integrate USDC [checkout](https://docs.base.org/builderkits/onchainkit/checkout/checkout) flows with ease. - [**`Fund`**](https://docs.base.org/builderkits/onchainkit/fund/fund-button)\- Create a [funding](https://docs.base.org/builderkits/onchainkit/fund/fund-button) flow to onboard users. - [**`Tokens`**](https://docs.base.org/builderkits/onchainkit/token/token-chip)\- Search and display [tokens](https://docs.base.org/builderkits/onchainkit/token/token-chip) with various components. - [**`Swap`**](https://docs.base.org/builderkits/onchainkit/swap/swap)\- Enable [token swaps](https://docs.base.org/builderkits/onchainkit/swap/swap) in your app. - [**`Mint`**](https://docs.base.org/builderkits/onchainkit/mint/nft-mint-card)- [View](https://docs.base.org/builderkits/onchainkit/mint/nft-mint-card) and [Mint](https://docs.base.org/builderkits/onchainkit/mint/nft-mint-card) NFTs in your app. We use cookies and similar technologies on our websites to enhance and tailor your experience, analyze our traffic, and for security and marketing. You can choose not to allow some type of cookies by clicking Manage Settings. For more information see our [Cookie Policy](https://docs.base.org/cookie-policy). Manage settings Accept all Skip to content Search Logo GitHub X Warpcast Discord Logo Get help GitHub X Warpcast Discord Menu How to Contribute On this page Chevron Right Welcome to OnchainKit! So you want to contribute to this project? You came to the right place. In this guide, you will learn how to: Set up this project Navigate the codebase Accomplish various workflows Submit a feature request Setup Clone the repo Copygit clone git@github.com:coinbase/onchainkit.git Install Node and pnpm Use nvm, mise, n or your favorite version manager to install Node.js. For pnpm, see the installation instructions on the pnpm website. Install dependencies From the root of the repository: Copypnpm install Codebase This project is a monorepo managed with pnpm. The @coinbase/onchainkit package is located in: Copypackages/onchainkit/ Here is a rough layout of the codebase: Copypackages/onchainkit/ └── src/ ├── api/ - API related components and functions ├── core/ - Files with zero dependencies ├── styles/ - Styles │ ├── index-with-tailwind.css - CSS entrypoint ├── {Component}/ - Component folder │ ├── components/ - React components │ │ ├── {Name}.tsx │ │ ├── {Name}.test.tsx │ │ └── {Name}.css │ ├── core/ - Utility functions │ ├── index.ts - Entrypoint for the folder │ └── types.ts - Export types │ ├── index.ts - Main package entry point ├── types.ts - Core types └── OnchainKitProvider.tsx - OnchainKit provider Workflows Development To work on OnchainKit components with live UI feedback: Copypnpm f:play dev This will build the OnchainKit package in watch mode, and start a development environment (the playground) where you can see your components in action. As you make changes, the playground will update automatically. Navigate to http://localhost:3000 to open the playground. Building To build the package: Copypnpm f:ock build Testing Write and update existing unit tests. You can run tests with: Copypnpm f:ock test For watching file changes and rerunning tests automatically: Copypnpm f:ock test:watch We expect 100% code coverage for any updates. You can get coverage information with: Copypnpm f:ock test:coverage If the coverage drops below 100%, look at the coverage report generated by the above command with: Copyopen coverage/index.html Updating changelog To update the change log, run: Copypnpm changeset Select minor and use the following format for the summary: Copy- **feat**: feature update information. By @your-github-id #XX (XX is the PR number) Possible values are: feat fix docs chore Feature request Have a component in mind that we are not supporting yet? You can submit a feature request to our Github. Create a "New issue" and label it "Feature Request: ...". We use cookies and similar technologies on our websites to enhance and tailor your experience, analyze our traffic, and for security and marketing. You can choose not to allow some type of cookies by clicking Manage Settings. For more information see our Cookie Policy. Manage settings Accept all [Skip to content](https://docs.base.org/builderkits/onchainkit/installation/astro#vocs-content) Astro On this page Chevron Right Install and configure OnchainKit with Astro. If you are integrating OnchainKit into an existing project, skip to the [OnchainKit installation](https://docs.base.org/builderkits/onchainkit/installation/astro#install-onchainkit). ## Install Astro Create a new Astro project by using the Astro CLI. More information about Astro can be found [here](https://docs.astro.build/en/install-and-setup/#start-a-new-project). npmyarnpnpm Terminal npm ```vocs_Code Copynpm create astro@latest ``` ## Install React Astro does not come with React by default, so if you are not already using React in your application, you will need to install it. Terminal Terminal ```vocs_Code Copynpx astro add react ``` ## Install OnchainKit Add OnchainKit to your project by installing the `@coinbase/onchainkit` package. npmyarnpnpmbun Terminal npm ```vocs_Code Copynpm install @coinbase/onchainkit ``` ## Get A Client API Key Get your [Client API Key](https://portal.cdp.coinbase.com/projects/api-keys/client-key) from Coinbase Developer Platform. ![OnchainKit copy Client API Key](https://docs.base.org/images/onchainkit/copy-api-key-guide.png) Create a `.env` file in your project's root directory. ![OnchainKit define Client API Key](https://docs.base.org/images/onchainkit/getting-started-create-env-file.png) Add your Client API Key to the `.env` file: File .env ```vocs_Code CopyPUBLIC_ONCHAINKIT_API_KEY=YOUR_CLIENT_API_KEY ``` ## Add Providers Create a `providers.tsx` file. Add `OnchainKitProvider` with your desired config. Under the hood, OnchainKit will create our recommended Wagmi and QueryClient providers. If you wish to customize these providers, check out [Custom\\ Supplemental Providers](https://docs.base.org/builderkits/onchainkit/config/supplemental-providers). File providers.tsx ```vocs_Code Copy'use client'; import type { ReactNode } from 'react'; import { OnchainKitProvider } from '@coinbase/onchainkit'; import { base } from 'wagmi/chains'; // add baseSepolia for testing export function Providers(props: { children: ReactNode }) { return ( {props.children} ); } ``` ## Wrap your OnchainKit components with `` After configuring the providers in step 4, you will need to wrap your OnchainKit components with the `` component. There are two options for this: 1. Create a component, eg. `` that contains all OnchainKit components. 2. Wrap every OnchainKit component individually. ReactIslandOnchainKit Wrappers ReactIsland ```vocs_Code Copyimport { AppProviders } from '../AppProviders'; export default function ReactIsland() { return ( ); } ``` The advantage of ReactIsland is that you will only have a single provider at any time. The drawback is that your OnchainKit components will all need to live in the same Island. The advantage of individual wrappers is that you can use OnchainKit components anywhere in your app. The drawback is that you will have multiple providers if you use more than one OnchainKit component. ## Add OnchainKit Components to your App You can add OnchainKit components to your app by using the component(s) you created above into your `.astro` files. For example, if you created a ReactIsland, you can add it to your `src/pages/index.astro` file: File src/pages/index.astro ```vocs_Code Copy--- import Layout from '../layouts/Layout.astro'; import ReactIsland from '../components/ReactIsland'; ---
... ...
``` Don't forget to add the `client:only="react"` directive to your OnchainKit component, as this is required for Astro to render React components. ## Import OnchainKit Styles OnchainKit components come with pre-configured styles. To include these styles in your project, add the following import statement at the top of the `Layout.astro` file: ```vocs_Code Copyimport '@coinbase/onchainkit/styles.css'; ``` This ensures that the OnchainKit styles are loaded and applied to your entire application. - For Tailwind CSS users, check out our [Tailwind Integration Guide](https://docs.base.org/builderkits/onchainkit/guides/tailwind). - Update the appearance of components by using our built-in themes or crafting your own custom theme. Explore the possibilities in our [Theming Guide](https://docs.base.org/builderkits/onchainkit/guides/themes). # Start building! Explore our ready-to-use onchain components: - [**`Identity`**](https://docs.base.org/builderkits/onchainkit/identity/identity)\- Show [Basenames](https://docs.base.org/builderkits/onchainkit/identity/identity), [avatars](https://docs.base.org/builderkits/onchainkit/identity/avatar), [badges](https://docs.base.org/builderkits/onchainkit/identity/badge), and [addresses](https://docs.base.org/builderkits/onchainkit/identity/address). - [**`Wallet`**](https://docs.base.org/builderkits/onchainkit/wallet/wallet)\- Create or connect wallets with [Connect Wallet](https://docs.base.org/builderkits/onchainkit/wallet/wallet). - [**`Transaction`**](https://docs.base.org/builderkits/onchainkit/transaction/transaction)\- Handle [transactions](https://docs.base.org/builderkits/onchainkit/transaction/transaction) using EOAs or Smart Wallets. - [**`Checkout`**](https://docs.base.org/builderkits/onchainkit/checkout/checkout)\- Integrate USDC [checkout](https://docs.base.org/builderkits/onchainkit/checkout/checkout) flows with ease. - [**`Fund`**](https://docs.base.org/builderkits/onchainkit/fund/fund-button)\- Create a [funding](https://docs.base.org/builderkits/onchainkit/fund/fund-button) flow to onboard users. - [**`Tokens`**](https://docs.base.org/builderkits/onchainkit/token/token-chip)\- Search and display [tokens](https://docs.base.org/builderkits/onchainkit/token/token-chip) with various components. - [**`Swap`**](https://docs.base.org/builderkits/onchainkit/swap/swap)\- Enable [token swaps](https://docs.base.org/builderkits/onchainkit/swap/swap) in your app. - [**`Mint`**](https://docs.base.org/builderkits/onchainkit/mint/nft-mint-card)- [View](https://docs.base.org/builderkits/onchainkit/mint/nft-mint-card) and [Mint](https://docs.base.org/builderkits/onchainkit/mint/nft-mint-card) NFTs in your app. We use cookies and similar technologies on our websites to enhance and tailor your experience, analyze our traffic, and for security and marketing. You can choose not to allow some type of cookies by clicking Manage Settings. For more information see our [Cookie Policy](https://docs.base.org/cookie-policy). Manage settings Accept all [Skip to content](https://docs.base.org/builderkits/onchainkit/installation/remix#vocs-content) Remix On this page Chevron Right Install and configure OnchainKit with Remix. If you are integrating OnchainKit into an existing project, skip to the [OnchainKit installation](https://docs.base.org/builderkits/onchainkit/installation/remix#install-onchainkit). ## Install Remix Create a new Remix project by using the Remix CLI. More information about Remix can be found [here](https://remix.run/docs/en/main/start/quickstart). Terminal Terminal ```vocs_Code Copynpx create-remix@latest ``` ## Install OnchainKit Add OnchainKit to your project by installing the `@coinbase/onchainkit` package. npmyarnpnpmbun Terminal npm ```vocs_Code Copynpm install @coinbase/onchainkit ``` ## Get A Client API Key Get your [Client API Key](https://portal.cdp.coinbase.com/projects/api-keys/client-key) from Coinbase Developer Platform. ![OnchainKit copy Client API Key](https://docs.base.org/images/onchainkit/copy-api-key-guide.png) Create a `.env` file in your project's root directory. ![OnchainKit define Client API Key](https://docs.base.org/images/onchainkit/getting-started-create-env-file.png) Add your Client API Key to the `.env` file: File .env ```vocs_Code CopyPUBLIC_ONCHAINKIT_API_KEY=YOUR_CLIENT_API_KEY ``` Update the `app/root.tsx` file to provide access to your Client API Key through `window.ENV`: File app/root.tsx ```vocs_Code Copydeclare global { interface Window { ENV: { PUBLIC_ONCHAINKIT_API_KEY: string; }; } } export async function loader() { return json({ ENV: { PUBLIC_ONCHAINKIT_API_KEY: process.env.PUBLIC_ONCHAINKIT_API_KEY, }, }); } ``` If this is the first env variable you've added to your project, you will need to update the `Layout` component of `app/root.tsx` to make it available to your app: File app/root.tsx ```vocs_Code Copyexport function Layout({ children }: { children: React.ReactNode }) { const data = useLoaderData(); return ( {children}