npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-rgb

v0.2.4

Published

React Native library for Bitcoin RGB Protocol

Readme

react-native-rgb

A React Native Turbo Module for the Bitcoin RGB Protocol. This library provides a high-level TypeScript API to manage RGB assets, keys, and wallets. It wraps the native rgb-lib-swift and rgb-lib-kotlin libraries.

Table of Contents

Features

  • Full Asset Support: Handle NIA, UDA, CFA, and IFA.
  • Key Management: BIP39 mnemonic support for key generation and restoration.
  • Performance: Built as a Turbo Module for efficient native communication.
  • Type Safety: Written in TypeScript.

Installation

yarn add react-native-rgb

iOS Setup

The native Rust framework (rgb_libFFI.xcframework) is automatically downloaded during postinstall.

cd ios && pod install

Android Setup

The library requires minSdkVersion 24. Make sure your android/build.gradle includes JitPack if necessary for transitive dependencies:

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

Quick Start

1. Setup Keys

import { generateKeys, BitcoinNetwork } from 'react-native-rgb';

const keys = await generateKeys(BitcoinNetwork.TESTNET4);

2. Initialize Wallet

import { Wallet } from 'react-native-rgb';

const wallet = new Wallet(keys, { network: BitcoinNetwork.TESTNET4 });

3. Basic Operations

// Bring the wallet online
await wallet.goOnline('ssl://electrum.iriswallet.com:50053');

// Issue a new NIA asset
const asset = await wallet.issueAssetNia('TICKER', 'Name', 2, [1000]);

// Check your balance
const btcBalance = await wallet.getBtcBalance();

Error Handling

The library uses structured error handling with error codes for better error management. All methods that can fail will throw an RgbError with a specific error code.

Using RgbError

import { Wallet, RgbError, RgbErrorCode } from 'react-native-rgb';

try {
  await wallet.goOnline('ssl://indexer.example.com:50053');
} catch (error) {
  // Convert React Native error to RgbError
  const rgbError = RgbError.fromReactNativeError(error);
  
  if (rgbError instanceof RgbError) {
    // Handle specific error codes
    switch (rgbError.code) {
      case RgbErrorCode.GO_ONLINE_ERROR:
        console.error('Failed to connect:', rgbError.message);
        // Handle connection error
        break;
      case RgbErrorCode.INITIALIZE_WALLET_ERROR:
        console.error('Wallet initialization failed:', rgbError.message);
        // Handle initialization error
        break;
      default:
        console.error(`Error [${rgbError.code}]:`, rgbError.message);
    }
  } else {
    // Handle generic errors
    console.error('Unexpected error:', error);
  }
}

API Reference

Keys & Wallet Setup

  • generateKeys(network) / restoreKeys(network, mnemonic)
  • new Wallet(keys, options): Options include network, maxAllocationsPerUtxo, and vanillaKeychain.

Wallet

  • goOnline(indexerUrl, skipSync?): Connect to infrastructure.
  • sync(): Manually trigger a blockchain sync.
  • close(): Shut down the wallet and free native resources.

Balance & Assets

  • getBtcBalance(): Returns { vanilla: Balance, colored: Balance }.
  • getAddress(): Returns the funding address.
  • getAssetBalance(assetId) / getAssetMetadata(assetId)
  • listAssets(filter[]): List assets by schema (NIA, UDA, CFA, IFA).

Asset Issuance

  • issueAssetNia(ticker, name, precision, amounts)
  • issueAssetCfa(name, details, precision, amounts, filePath?)
  • issueAssetUda(ticker, name, details, precision, mediaPath, attachments[])
  • issueAssetIfa(ticker, name, precision, amounts, ...)

Sending & Receiving

  • blindReceive(assetId, amount, duration, endpoints, confirmations): Get a blinded invoice.
  • witnessReceive(...): Get a witness invoice.
  • send(recipientMap, donation, feeRate, confirmations): Send RGB assets.
  • sendBtc(address, amount, feeRate): Send regular Bitcoin.

Project Structure

  • src/: TypeScript source (Wallet class, Interfaces).
  • android/ & ios/: Native Turbo Module implementations.
  • scripts/: Build and setup scripts.
  • example/: Sample React Native app.

Running the Example

  1. yarn install (root)
  2. yarn prepare (build library)
  3. cd example && yarn install
  4. cd ios && pod install
  5. yarn ios or yarn android

Troubleshooting

  • iOS framework: If a postinstall fails, run node scripts/download-rgb-lib-ios.js manually.
  • Linker issues: Ensure you use the .xcworkspace on iOS.
  • Android SDK: Must have minSdkVersion >= 24.

License

MIT