The BOB Gateway SDK makes it easy to bring Bitcoin onramp functionality directly into your app. This guide walks through the complete integration process.We recommend using the API directly, but you may use our SDK for convenience.
Request a quote for the user’s desired transaction:
Copy
Ask AI
import { parseBtc } from '@gobob/bob-sdk';import { parseEther } from 'viem';const quote = await gatewaySDK.getQuote({ fromChain: 'bitcoin', fromToken: '0x0000000000000000000000000000000000000000', fromUserAddress: 'bc1qafk4yhqvj4wep57m62dgrmutldusqde8adh20d', toChain: 'bob', toToken: '0x0555E30da8f98308EdB960aa94C0Db47230d2B9c', toUserAddress: '0x2D2E86236a5bC1c8a5e5499C517E17Fb88Dbc18c', amount: parseBtc("0.1"), // 0.1 BTC gasRefill: parseEther("0.00001"), // Optional ETH gas refill});
Token parameters (fromToken, toToken) must be 0x-prefixed hex addresses, not symbols. Use getRoutes() to find supported token addresses. For BTC, use the zero address 0x0000000000000000000000000000000000000000.
Display quote fields like fees and estimated time to give users transparency about the transaction. See the section below for how to access these fields.
The getQuote response is a discriminated union — access fields through the appropriate key:
Copy
Ask AI
const quote = await gatewaySDK.getQuote({ /* ... */ });if ('onramp' in quote) { // Bitcoin → BOB onramp console.log('Input:', quote.onramp.inputAmount); console.log('Fees:', quote.onramp.feeBreakdown); console.log('ETA:', quote.onramp.estimatedTimeInSecs, 'seconds');} else if ('offramp' in quote) { // BOB → Bitcoin offramp console.log('Input:', quote.offramp.inputAmount); console.log('Fees:', quote.offramp.feeBreakdown); console.log('ETA:', quote.offramp.estimatedTimeInSecs, 'seconds');} else if ('layerZero' in quote) { // Cross-chain via LayerZero console.log('Input:', quote.layerZero.inputAmount); console.log('Fees:', quote.layerZero.fees); console.log('ETA:', quote.layerZero.estimatedTimeInSecs, 'seconds');}
You don’t need to handle all quote types — the response type matches your fromChain/toChain parameters. For example, fromChain: 'bitcoin' with toChain: 'bob' always returns an onramp quote.