React Native wrapper for libauth with full CashTokens support
npm install @arquebus-io/libauth-react-nativeReact Native wrapper for libauth with full CashTokens support.
Uses Polygen to compile WebAssembly to native code for iOS and Android.
``bash`
npm install @yourorg/libauth-react-nativeor
yarn add @yourorg/libauth-react-native
bash
cd ios && pod install
`$3
No additional steps - Gradle handles it automatically.Usage
Use exactly like the original libauth:
`typescript
import {
generatePrivateKey,
derivePublicKeyUncompressed,
encodeCashAddress
} from '@yourorg/libauth-react-native';// Generate wallet
const privateKey = generatePrivateKey();
const publicKey = derivePublicKeyUncompressed(privateKey);
const address = encodeCashAddress('bitcoincash', {
type: 'p2pkh',
payload: publicKey,
});
console.log('Address:', address);
`$3
Full support for CashTokens operations:
`typescript
import {
encodeTokenPrefix,
decodeTokenPrefix,
encodeFungibleTokenAmount
} from '@yourorg/libauth-react-native';// Create a token-aware transaction
const tokenPrefix = encodeTokenPrefix({
category: categoryId,
nft: {
capability: 'minting',
commitment: commitmentData
}
});
`$3
All libauth features are available:
- Wallet Operations: Key generation, HD wallets, address encoding/decoding
- Transaction Building: Complete transaction construction and signing
- Script Evaluation: Full Bitcoin Script VM implementation
- CashTokens: Complete fungible and NFT token support
- Authentication Templates: Bitauth IDE template support
- Crypto Operations: SHA256, RIPEMD160, Secp256k1, and more
Performance
- WASM crypto operations run at native speed
- ~50x faster than pure JS implementations
- No overhead - Polygen compiles WASM ahead of time
API Documentation
This library re-exports all functions from
@bitauth/libauth. For complete API documentation, see:- libauth Documentation
- API Reference
Example App
See the
example/ directory for a complete React Native app demonstrating:- Wallet generation
- Address derivation
- Transaction building
- CashTokens operations
Requirements
- React Native >= 0.60
- iOS >= 12.0
- Android minSdkVersion >= 21
Development
$3
`bash
Install dependencies
npm installBuild TypeScript
npm run buildRun tests
npm testLink for development
npm link
`$3
For maximum performance, you can compile the WASM modules to native C code:
1. Install WABT (WebAssembly Binary Toolkit)
2. Set the WABT_PATH environment variable:
`bash
export WABT_PATH=/path/to/wabt/bin
`3. Generate native code:
`bash
npm run generate-native
`This generates C source files from libauth's WASM modules (secp256k1, sha256, ripemd160, etc.) which are then compiled to native code when building the iOS/Android apps.
$3
`
libauth-react-native/
├── src/ # TypeScript source
├── lib/ # Compiled JavaScript
├── ios/ # iOS native module
│ └── Polygen/ # WASM compiled frameworks
├── android/ # Android native module
│ └── libs/ # WASM compiled libraries
└── example/ # Example React Native app
`Troubleshooting
$3
If you encounter build errors on iOS:
`bash
cd ios
pod deintegrate
pod install
`$3
Clear the build cache:
`bash
cd android
./gradlew clean
cd ..
npx react-native run-android
`Contributing
1. Fork the repository
2. Create your feature branch (
git checkout -b feature/amazing-feature)
3. Commit your changes (git commit -m 'Add amazing feature')
4. Push to the branch (git push origin feature/amazing-feature`)MIT
- libauth - The powerful Bitcoin library
- Polygen - WASM to native compilation
- React Native community