From 414e7475cd0bbb814566a498283aeb1a8014130c Mon Sep 17 00:00:00 2001 From: Suryateja Mandadi Date: Wed, 19 Nov 2025 14:14:38 -0800 Subject: [PATCH] updating docs to include session token more explicitly --- docs/onchainkit/fund/fund-button.mdx | 300 ++++++++---------- docs/onchainkit/fund/fund-card.mdx | 273 +++++++++------- .../latest/components/fund/fund-button.mdx | 294 +++++++---------- .../latest/components/fund/fund-card.mdx | 243 +++++++------- 4 files changed, 542 insertions(+), 568 deletions(-) diff --git a/docs/onchainkit/fund/fund-button.mdx b/docs/onchainkit/fund/fund-button.mdx index ed5f63ee..4b03c0da 100644 --- a/docs/onchainkit/fund/fund-button.mdx +++ b/docs/onchainkit/fund/fund-button.mdx @@ -1,117 +1,111 @@ --- -title: · OnchainKit +title: sidebarTitle: -description: The `` component provides a way for users to onramp from fiat to crypto from within your app. +description: The `` component provides a way for users to fund their wallet without leaving your app. --- +# FundButton + The `` component provides a way for users to fund their wallet without leaving your app. It automatically detects the user's wallet type (EOA vs Smart Wallet) and directs them to the appropriate funding URL. -If your user connects a Coinbase Smart Wallet, it provides an easy way to access the Coinbase Smart Wallet -[Fund](https://keys.coinbase.com/fund) flow. Users will be able to buy and receive crypto, or use their Coinbase +If your user connects a Coinbase Smart Wallet, it provides an easy way to access the Coinbase Smart Wallet +[Fund](https://keys.coinbase.com/fund) flow. Users will be able to buy and receive crypto, or use their Coinbase balances onchain with [Magic Spend](https://www.smartwallet.dev/guides/magic-spend). If your user connects any other EOA wallet, it provides an easy way to access [Coinbase Onramp](https://docs.cdp.coinbase.com/onramp/docs/welcome/) where your users will also be able to buy crypto using a fiat payment method, or transfer existing crypto from their Coinbase account. -Before using it, ensure you've completed all [Getting Started steps](/onchainkit/getting-started). - ## Walkthrough - 1. Get your Project ID from the [Coinbase Developer Platform Dashboard](https://portal.cdp.coinbase.com/). + 1. Get your Project ID from the [Coinbase Developer Platform Dashboard](https://portal.cdp.coinbase.com/). - - OnchainKit copy Project Id - + + OnchainKit copy Project Id + - 2. Add your Project ID to your `.env` file. + 2. Add your Project ID to your `.env` file. + + ```tsx .env theme={null} + NEXT_PUBLIC_ONCHAINKIT_API_KEY=YOUR_PUBLIC_API_KEY + NEXT_PUBLIC_CDP_PROJECT_ID=YOUR_CDP_PROJECT_ID // [!code ++] + ``` - ```tsx .env - // @noErrors - NEXT_PUBLIC_ONCHAINKIT_API_KEY=YOUR_PUBLIC_API_KEY - NEXT_PUBLIC_CDP_PROJECT_ID=YOUR_CDP_PROJECT_ID // [!code ++] - ``` - - ```tsx - // @noErrors + + + ```tsx theme={null} {props.children} ``` - - - ```tsx - import { FundButton } from '@coinbase/onchainkit/fund'; - - - ``` + + + + [Getting session + token](https://docs.cdp.coinbase.com/onramp-&-offramp/session-token-authentication) + + + + ```tsx theme={null} + import { FundButton } from '@coinbase/onchainkit/fund'; + + const sessionToken = "YOUR_SESSION_TOKEN"; + + // can use EITHER sessionToken or fundingUrl + + ``` + + {/* + + {({ address }) => { + if (address) { + return ( + + ) + } + return <> + + + + + + + ; + }} + + */} - - - {({ address }) => { - if (address) { - return ( - - ) - } - return <> - - - - - - - ; - }} - - - - -**Troubleshooting** - -If you see a "something went wrong" error message when navigating to pay.coinbase.com, make sure you have "enforce -secure initialization" disabled on the [Onramp config page in Coinbase Developer Platform Dashboard](https://portal.cdp.coinbase.com/products/onramp). - - -OnchainKit require secure init - - - - - ## Customizing the funding experience -You can customize the Coinbase Onramp experience by bringing your own Onramp URL and passing it to the `````` +You can customize the Coinbase Onramp experience by bringing your own Onramp URL and passing it to the `` component. We provide the [`getOnrampBuyUrl`](/onchainkit/fund/get-onramp-buy-url) utility to help you generate a Coinbase Onramp URL tailored to your use case. -```tsx -import { FundButton, getOnrampBuyUrl } from '@coinbase/onchainkit/fund'; -import { useAccount } from 'wagmi'; +```tsx theme={null} +import { FundButton, getOnrampBuyUrl } from "@coinbase/onchainkit/fund"; +import { useAccount } from "wagmi"; -const projectId = 'YOUR_CDP_PROJECT_ID'; +const projectId = "YOUR_CDP_PROJECT_ID"; const { address } = useAccount(); const onrampBuyUrl = getOnrampBuyUrl({ - projectId, - addresses: { [address]: ['base'] }, - assets: ['USDC'], + sessionToken: "YOUR_SESSION_TOKEN", presetFiatAmount: 20, - fiatCurrency: 'USD' + fiatCurrency: "USD", }); - +; ```