🚀 DAY 3 OF LAUNCH WEEK: Introducing Webhook Events for Pull Request Scans.Learn more
Socket
Book a DemoInstallSign in
Socket

@fedimint/core-web

Package Overview
Dependencies
Maintainers
5
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fedimint/core-web

Library for building web apps with a fedimint client

npmnpm
Version
0.0.0-canary-20240920231718
Version published
Weekly downloads
170
-32%
Maintainers
5
Weekly downloads
 
Created
Source

@fedimint/core-web

THIS IS A WORK IN PROGRESS AND NOT READY FOR SERIOUS USE

This package provides a typescript interface for a fedimint client in the browser.

It contains the wasm-pack output of the rust-based fedimint client.

Key Features:

  • WebAssembly-powered Client: Exposes the robust, fault-tolerant fedimint-client (built in Rust) via WebAssembly. Lazy-Loads within a web worker for performance.
  • eCash Payments: Includes support for joining federations, sending/receiving eCash, and managing balances.
  • Lightning Payments: Ships with zero-setup Lightning Network payments.
  • 🛠️ State Management: Handles the complex state management and storage challenges for browser wallets.
  • 🤫 Privacy Included: Offers a privacy-centric wallet by default.
  • ⚙️ Framework Agnostic: Designed as a "core" library compatible with vanilla JavaScript, laying the groundwork for future framework-specific packages.

Installation

// npm or yarn or pnpm
pnpm add @fedimint/core-web

Setup

This package relies on the wasm binary to be bundled with your application. You will likely need to update your bundler's or framework's configuration to load the wasm file. Setup guides for popular frameworks are coming soon.

See the vite.config.ts file in the vite-core example for an example of configuring wasm within a web-worker using Vite.

Usage

import { FedimintWallet } from '@fedimint/core-web'

// Create the Wallet client
const wallet = new FedimintWallet()

// This should be called only once in the application
// lifecycle. It will automatically load your saved
// wallet state from previous sessions.
await wallet.open()

// Joining a Federation

// You can't join a federation
// if your wallet is already open
if (!wallet.isOpen()) {
  // Check out [bitcoin mints](https://bitcoinmints.com/?tab=mints&showFedimint=true) for
  // a list of federations with public invite codes.
  const inviteCode = 'fed11qgqpw9thwvaz7t...'

  await wallet.joinFederation(inviteCode)
  // After you've joined a federation, your federation state
  // will be stored in the browser. Future calls to `open()`
  // will automatically load your saved federation.
}

// Get Wallet Balance (sync)
const balance = await wallet.getBalance()

// Subscribe to Balance Updates
const unsubscribe = wallet.subscribeBalance((balance: number) => {
  console.log('updated balance', balance)
})
// Make sure to call `unsubscribe()` when you're done

// Receive Ecash Payments
await wallet.reissueNotes('A11qgqpw9thwvaz7t...')

// Pay Lightning Invoice
await wallet.payBolt11Invoice('lnbc...')

Check out the example

Resources

FAQs

Package last updated on 20 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts