@mrimmortal09/react-native-fedimint-client
v0.1.5
Published
fedimint uniffi bindings for react native
Maintainers
Readme
@mrimmortal09/react-native-fedimint-client
A React Native client library for Fedimint, featuring Rust bindings generated via UniFFI. This package is pre-configured with necessary patches and binary optimizations for smooth usage.
📦 Installation
yarn add @mrimmortal09/react-native-fedimint-clientUsage
📱 Compatibility & Requirements
- Android:
arm64-v8a: Supported (Modern Devices)x86_64: Supported (Emulators)armeabi-v7a: Not supported.
- iOS:
arm64: Supported (Physical Devices).x86_64: Supported (Simulator).- Note for M1/M2 Users: To run on Simulator, you must run it in Rosetta mode (which uses
x86_64), as nativearm64simulator support is currently blocked by upstream dependencies.
- Expo: Requires Development Build (prebuild). This is a native module.
1. Initialize the Client
You must verify that the database path exists and is writable before initializing the client.
import { setup, sendRpc } from '@mrimmortal09/react-native-fedimint-client';
// Option 1: React Native CLI (using react-native-fs)
import RNFS from 'react-native-fs';
const initFedimintCLI = async () => {
const dbPath = `${RNFS.DocumentDirectoryPath}/fedimint_db`;
console.log("Using DB Path:", dbPath);
setup(dbPath);
};
// Option 2: Expo (using expo-file-system)
import { Paths } from 'expo-file-system';
const initFedimintExpo = async () => {
try {
const dbUriPath = Paths.document.uri; // e.g. file:///data/...
// Strip the file:// scheme to get the plain filesystem path
const dbPath = dbUriPath.replace(/^file:\/\//, '');
console.log("Using DB Path:", dbPath);
setup(dbPath);
console.log("Setup called successfully with path: " + dbPath);
} catch (e: any) {
console.error("Setup failed:", e);
}
};2. Send RPC Commands
Once initialized, you can send JSON RPC commands to the underlying Fedimint client.
const getInfo = async () => {
try {
const response = await sendRpc(JSON.stringify({ "request_id": "1", "method": "has_mnemonic_set" }));
console.log('Fedimint Info:', response);
} catch (error) {
console.error('RPC Error:', error);
}
};License
MIT
