@web5nexus/authmodal-bitcoin
v0.1.0
Published
Web5 Nexus Auth Modal — Bitcoin-first social wallet (Web3Auth key export + bitcoin-core addresses, PSBT, Ordinals, BRC-20, Runes)
Readme
@web5nexus/authmodal-bitcoin
Bitcoin-first social wallet for the BTC community. Social login via Web3Auth (key export) → derive Taproot / SegWit / Legacy / Nested SegWit with @web5nexus/bitcoin-core → balance, PSBT, Ordinals, BRC-20, Runes.
Install
npm install @web5nexus/authmodal-bitcoin @web5nexus/authmodal-coreHosts also need the Web3Auth Vite helpers (same as @web5nexus/authmodal-web3auth):
import '@web5nexus/authmodal-web3auth/polyfill' // before other imports
import {
bitcoinOptimizeDeps,
bitcoinProcessPolyfillPlugin,
bitcoinViteAliases,
} from '@web5nexus/authmodal-bitcoin/vite'Headless client
import { bitcoinAuth } from '@web5nexus/authmodal-bitcoin'
const btc = bitcoinAuth({
clientId: process.env.W3A_CLIENT_ID!,
bitcoinNetwork: 'mainnet',
addressTypes: ['taproot', 'segwit', 'legacy', 'nested-segwit'],
prefer: 'taproot',
})
const session = await btc.connect({ method: 'google' })
console.log(session.addresses.primary) // bc1p…
console.log(session.addresses.byType)
const balance = await btc.getBalance() // sats
const utxos = await btc.getUtxos()
// Explicit opt-in — never persisted by the SDK
const wif = await btc.exportWif()React
import {
BitcoinWalletProvider,
useBitcoinWallet,
usePsbt,
useOrdinals,
useBrc20,
useRunes,
} from '@web5nexus/authmodal-bitcoin/react'
function App() {
return (
<BitcoinWalletProvider
clientId={import.meta.env.VITE_W3A_CLIENT_ID}
bitcoinNetwork="mainnet"
addressTypes={['taproot', 'segwit']}
prefer="taproot"
>
<Wallet />
</BitcoinWalletProvider>
)
}
function Wallet() {
const { connect, primary, addresses, getBalance, isConnected } = useBitcoinWallet()
const { send, busy } = usePsbt()
const ordinals = useOrdinals()
const brc20 = useBrc20()
return (
<>
{!isConnected && (
<button onClick={() => void connect({ method: 'google' })}>Connect Bitcoin</button>
)}
{primary && <code>{primary}</code>}
</>
)
}Address types (dev-selected)
| Id | Script | Example prefix |
|----|--------|----------------|
| taproot | P2TR | bc1p… |
| segwit | P2WPKH | bc1q… |
| legacy | P2PKH | 1… |
| nested-segwit | P2SH-P2WPKH | 3… |
Same secp256k1 key from social login; types are encodings, not separate wallets.
Protocols
Re-exported from @web5nexus/bitcoin-core:
bitcoinProtocols.ordinals/useOrdinals()bitcoinProtocols.brc20/useBrc20()bitcoinProtocols.runes/useRunes()bitcoinProtocols.utils— balance, UTXOs, broadcast, validate
Security
- Private keys stay in memory only for the session.
- Prefer
usePsbt/buildAndSignover exporting keys in production UIs. - Requires Web3Auth dashboard key export enabled.
License
MIT
