Skip to content

Commit

Permalink
add bitcoin docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rtomas committed Dec 3, 2024
1 parent 04e177f commit 05e3582
Show file tree
Hide file tree
Showing 15 changed files with 405 additions and 20 deletions.
59 changes: 59 additions & 0 deletions docs/appkit/features/bitcoin.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
pagination_next: appkit/react/core/installation
title: Bitcoin
---

import Button from '../../components/button'
import Container from '../../components/Container.js'
import Wrapper from '../../components/Home/Wrapper'
import W3MQuickStart from '../../components/W3MQuickStart'
import useBaseUrl from '@docusaurus/useBaseUrl'

import reactLogo from '../../../static/assets/home/reactLogo.png'
import nextjsLogo from '../../../static/assets/home/nextjsLogo.png'
import vueLogo from '../../../static/assets/home/vueLogo.png'
import javascriptLogo from '../../../static/assets/home/javascriptLogo.png'

# Bitcoin

The AppKit SDK supports Bitcoin, allowing users to connect their Bitcoin wallets to applications. AppKit provides a simple, secure, and seamless in-app experience for users looking to transact within web3.

<Button name="Try Demo" url="https://appkit-lab.reown.com/library/bitcoin/" />

## Get Started

<Wrapper
type="large"
fit={false}
items={[
{
name: 'React',
type: 'react',
description: 'Get started with AppKit in React.',
icon: reactLogo,
href: '../react/core/installation?platform=bitcoin'
},
{
name: 'Next.js',
type: 'next',
description: 'Get started with AppKit in Next.js.',
icon: nextjsLogo,
href: '../next/core/installation?platform=bitcoin',
isWhite: true
},
{
name: 'Vue',
type: 'vue',
description: 'Get started with AppKit in Vue.',
icon: vueLogo,
href: '../vue/core/installation?platform=bitcoin'
},
{
name: 'JavaScript',
type: 'javascript',
description: 'Get started with AppKit in JavaScript.',
icon: javascriptLogo,
href: '../javascript/core/installation?platform=bitcoin'
}
]}
/>
50 changes: 50 additions & 0 deletions docs/appkit/javascript/bitcoin/about/implementation.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
AppKit Bitcoin is built on top of the AppKit library and provides a set of components and actions to easily connect Bitcoin wallets with your decentralized application.

On top of your app set up the following configuration.

```tsx
// App.tsx
import { createAppKit } from '@reown/appkit'
import { BitcoinAdapter } from '@reown/appkit-adapter-bitcoin'
import { bitcoin, bitcoinTestnet } from '@reown/appkit/networks'

// 1. Get projectId from https://cloud.reown.com
const projectId = 'YOUR_PROJECT_ID'

// 2. Set the networks
const networks = [bitcoin, bitcoinTestnet] as [AppKitNetwork, ...AppKitNetwork[]]

// 3. Set up Bitcoin Adapter
const bitcoinAdapter = new BitcoinAdapter({
networks,
projectId
})

// 4. Create a metadata object - optional
const metadata = {
name: 'AppKit',
description: 'AppKit Bitcoin Example',
url: 'https://example.com', // origin must match your domain & subdomain
icons: ['https://avatars.githubusercontent.com/u/179229932']
}

// 5. Create modal
const modal = createAppKit({
adapters: [bitcoinAdapter],
networks,
metadata,
projectId,
features: {
analytics: true // Optional - defaults to your Cloud configuration,
email: false,
socials: []
}
})

// 6. Trigger modal programaticaly
const openConnectModalBtn = document.getElementById('open-connect-modal')
const openNetworkModalBtn = document.getElementById('open-network-modal')

openConnectModalBtn.addEventListener('click', () => modal.open())
openNetworkModalBtn.addEventListener('click', () => modal.open({ view: 'Networks' }))
```
18 changes: 18 additions & 0 deletions docs/appkit/javascript/bitcoin/about/triggermodal.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
To open AppKit you can use our [**web component**](../../core/components.mdx) or build your own button with AppKit [**actions**](../../core/actions.mdx#open-and-close-the-modal).
In this example we are going to use the `<appkit-button>` component.

Web components are global html elements that don't require importing.

```tsx
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>HTML AppKit Example</title>
</head>
<body>
<appkit-button />
<script type="module" src="main.js"></script>
</body>
</html>
```
30 changes: 25 additions & 5 deletions docs/appkit/javascript/core/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,21 @@ import SolanaImplementation from '../solana/about/implementation.mdx'
import SolanaModal from '../solana/about/triggermodal.mdx'
import SolanaPrograms from '../solana/about/programs.mdx'

import BitcoinImplementation from '../bitcoin/about/implementation.mdx'
import BitcoinModal from '../bitcoin/about/triggermodal.mdx'

# JavaScript

AppKit has support for [Wagmi](https://wagmi.sh/) and [Ethers v6](https://docs.ethers.org/v6/) on Ethereum and [@solana/web3.js](https://solana-labs.github.io/solana-web3.js/) on Solana.
Choose one of these Ethereum Libraries or 'Solana' to get started.
AppKit has support for [Wagmi](https://wagmi.sh/) and [Ethers v6](https://docs.ethers.org/v6/) on Ethereum, [@solana/web3.js](https://solana-labs.github.io/solana-web3.js/) on Solana and Bitcoin.
Choose one of these to get started.

:::info Note
We recommend using [Vite](https://vitejs.dev/guide/#scaffolding-your-first-vite-project) to get started with AppKit JavaScript.
:::

## Installation

<PlatformTabs groupId="eth-lib" activeOptions={["wagmi", "ethers5", "ethers","solana"]}>
<PlatformTabs groupId="eth-lib" activeOptions={["wagmi", "ethers5", "ethers","solana","bitcoin"]}>
<PlatformTabItem value="wagmi">

```bash npm2yarn
Expand Down Expand Up @@ -57,6 +60,13 @@ npm install @reown/appkit @reown/appkit-adapter-ethers ethers
npm install @reown/appkit @reown/appkit-adapter-solana
```

</PlatformTabItem>
<PlatformTabItem value="bitcoin">

```bash npm2yarn
npm install @reown/appkit @reown/appkit-adapter-bitcoin bitcoinjs-lib
```

</PlatformTabItem>
</PlatformTabs>

Expand All @@ -68,7 +78,7 @@ Create a new project on Reown Cloud at https://cloud.reown.com and obtain a new

## Implementation

<PlatformTabs groupId="eth-lib" activeOptions={["wagmi", "ethers5", "ethers","solana"]}>
<PlatformTabs groupId="eth-lib" activeOptions={["wagmi", "ethers5", "ethers","solana","bitcoin"]}>
<PlatformTabItem value="wagmi">

<WagmiImplementation />
Expand All @@ -88,12 +98,17 @@ Create a new project on Reown Cloud at https://cloud.reown.com and obtain a new

<SolanaImplementation />

</PlatformTabItem>
<PlatformTabItem value="bitcoin">

<BitcoinImplementation />

</PlatformTabItem>
</PlatformTabs>

## Trigger the modal

<PlatformTabs groupId="eth-lib" activeOptions={["wagmi","ethers5", "ethers","solana"]}>
<PlatformTabs groupId="eth-lib" activeOptions={["wagmi","ethers5", "ethers","solana","bitcoin"]}>
<PlatformTabItem value="wagmi">

<WagmiModal />
Expand All @@ -113,6 +128,11 @@ Create a new project on Reown Cloud at https://cloud.reown.com and obtain a new

<SolanaModal />

</PlatformTabItem>
<PlatformTabItem value="bitcoin">

<BitcoinModal />

</PlatformTabItem>
</PlatformTabs>

Expand Down
47 changes: 47 additions & 0 deletions docs/appkit/next/bitcoin/about/implementation.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
AppKit Bitocin provides a set of React components and hooks to easily connect Bitcoin wallets with your application.

On top of your app set up the following configuration, making sure that all functions are called outside any React component to avoid unwanted rerenders.

```tsx
// App.tsx
import { createAppKit } from '@reown/appkit/react'
import { BitcoinAdapter } from '@reown/appkit-adapter-bitcoin'
import { bitcoin, bitcoinTestnet } from '@reown/appkit/networks'

// 1. Get projectId from https://cloud.reown.com
const projectId = 'YOUR_PROJECT_ID'

// 2. Set the networks
const networks = [bitcoin, bitcoinTestnet] as [AppKitNetwork, ...AppKitNetwork[]]

// 3. Set up Bitcoin Adapter
const bitcoinAdapter = new BitcoinAdapter({
networks,
projectId
})

// 4. Create a metadata object - optional
const metadata = {
name: 'AppKit',
description: 'AppKit Bitcoin Example',
url: 'https://example.com', // origin must match your domain & subdomain
icons: ['https://avatars.githubusercontent.com/u/179229932']
}

// 5. Create modal
createAppKit({
adapters: [bitcoinAdapter],
networks,
metadata,
projectId,
features: {
analytics: true // Optional - defaults to your Cloud configuration,
email: false,
socials: []
}
})

export default function App() {
return <YourApp />
}
```
10 changes: 10 additions & 0 deletions docs/appkit/next/bitcoin/about/triggermodal.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
To open AppKit you can use our default [web components](../../core/components.mdx) or build your own logic using [AppKit hooks](../../core/hooks.mdx).
In this example we are going to use the `<appkit-button>` component.

Web components are global html elements that don't require importing.

```tsx
export default function ConnectButton() {
return <appkit-button />
}
```
32 changes: 26 additions & 6 deletions docs/appkit/next/core/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ import SolanaImplementation from '../solana/about/implementation.mdx'
import SolanaModal from '../solana/about/triggermodal.mdx'
import SolanaPrograms from '../solana/about/programs.mdx'

import BitcoinImplementation from '../bitcoin/about/implementation.mdx'
import BitcoinModal from '../bitcoin/about/triggermodal.mdx'

# Next.js

AppKit has support for [Wagmi](https://wagmi.sh/) and [Ethers v6](https://docs.ethers.org/v6/) on Ethereum and [@solana/web3.js](https://solana-labs.github.io/solana-web3.js/) on Solana.
Choose one of these Ethereum Libraries or 'Solana' to get started.
AppKit has support for [Wagmi](https://wagmi.sh/) and [Ethers v6](https://docs.ethers.org/v6/) on Ethereum, [@solana/web3.js](https://solana-labs.github.io/solana-web3.js/) on Solana and Bitcoin.
Choose one of these to get started.

:::info Note
These steps are specific to [Next.js](https://nextjs.org/) app router. For other React frameworks read the [React documentation](../../react/core/installation.mdx).
Expand All @@ -33,7 +36,7 @@ These steps are specific to [Next.js](https://nextjs.org/) app router. For other

**If you prefer referring to a video tutorial for this, please [click here](#video-tutorial).**

<PlatformTabs groupId="eth-lib" activeOptions={["wagmi", "ethers5","ethers","solana"]}>
<PlatformTabs groupId="eth-lib" activeOptions={["wagmi", "ethers5","ethers","solana","bitcoin"]}>
<PlatformTabItem value="wagmi">

```bash npm2yarn
Expand Down Expand Up @@ -61,6 +64,13 @@ npm install @reown/appkit @reown/appkit-adapter-ethers ethers
npm install @reown/appkit @reown/appkit-adapter-solana @solana/wallet-adapter-wallets
```

</PlatformTabItem>
<PlatformTabItem value="bitcoin">

```bash npm2yarn
npm install @reown/appkit @reown/appkit-adapter-bitcoin bitcoinjs-lib
```

</PlatformTabItem>
</PlatformTabs>

Expand All @@ -72,7 +82,7 @@ Create a new project on Reown Cloud at https://cloud.reown.com and obtain a new

## Implementation

<PlatformTabs groupId="eth-lib" activeOptions={["wagmi", "ethers5","ethers","solana"]}>
<PlatformTabs groupId="eth-lib" activeOptions={["wagmi", "ethers5","ethers","solana","bitcoin"]}>
<PlatformTabItem value="wagmi">

<WagmiImplementation />
Expand All @@ -92,12 +102,17 @@ Create a new project on Reown Cloud at https://cloud.reown.com and obtain a new

<SolanaImplementation />

</PlatformTabItem>
<PlatformTabItem value="bitcoin">

<BitcoinImplementation />

</PlatformTabItem>
</PlatformTabs>

## Trigger the modal

<PlatformTabs groupId="eth-lib" activeOptions={["wagmi", "ethers5","ethers","solana"]}>
<PlatformTabs groupId="eth-lib" activeOptions={["wagmi", "ethers5","ethers","solana","bitcoin"]}>
<PlatformTabItem value="wagmi">

<WagmiModal />
Expand All @@ -117,12 +132,17 @@ Create a new project on Reown Cloud at https://cloud.reown.com and obtain a new

<SolanaModal />

</PlatformTabItem>
<PlatformTabItem value="bitcoin">

<BitcoinModal />

</PlatformTabItem>
</PlatformTabs>

## Smart Contract Interaction

<PlatformTabs groupId="eth-lib" activeOptions={["wagmi", "ethers","solana"]}>
<PlatformTabs groupId="eth-lib" activeOptions={["wagmi","ethers","solana"]}>
<PlatformTabItem value="wagmi">

[Wagmi hooks](https://wagmi.sh/react/api/hooks/useReadContract) can help us interact with wallets and smart contracts:
Expand Down
Loading

0 comments on commit 05e3582

Please sign in to comment.