Getting Started
This guide will help you get started with react-native-rgb and create your first RGB wallet.
Prerequisites
- React Native project (0.70+)
- Node.js 20+
- iOS: Xcode and CocoaPods
- Android: Android Studio with minSdkVersion 24+
Quick Start
1. Setup Keys
First, generate or restore keys for your wallet:
import { generateKeys, restoreKeys, BitcoinNetwork } from 'react-native-rgb';
// Generate new keys
const keys = await generateKeys(BitcoinNetwork.TESTNET4);
// Or restore from mnemonic
const keys = await restoreKeys(BitcoinNetwork.TESTNET4, 'your mnemonic phrase here');
The keys object contains:
mnemonic: The BIP39 mnemonic phrasexpub: Extended public keyaccountXpubVanilla: Account-level extended public key for vanilla transactionsaccountXpubColored: Account-level extended public key for colored transactionsmasterFingerprint: Master key fingerprint
2. Initialize Wallet
Create a new wallet instance with your keys:
import { Wallet, BitcoinNetwork } from 'react-native-rgb';
const wallet = new Wallet(keys, {
network: BitcoinNetwork.TESTNET4,
supportedSchemas: ['NIA', 'UDA', 'CFA'], // Optional, defaults to CFA, NIA, UDA
maxAllocationsPerUtxo: 1, // Optional, defaults to 1
vanillaKeychain: 0, // Optional, defaults to 0
});
3. Go Online
Connect your wallet to an RGB indexer:
await wallet.goOnline('ssl://electrum.iriswallet.com:50053');
4. Create UTXOs
UTXOs are needed for RGB operations. Create some:
const utxosCreated = await wallet.createUtxos(
false, // upTo
5, // num
1000, // size in sats
1.0 // feeRate in sat/vbyte
);
5. Issue an Asset
Issue your first RGB asset:
const asset = await wallet.issueAssetNia(
'TICKER', // ticker
'My Asset', // name
2, // precision
[1000, 2000] // amounts (each goes to a separate UTXO)
);
6. Check Balance
View your Bitcoin and asset balances:
// Bitcoin balance
const btcBalance = await wallet.getBtcBalance();
console.log('Vanilla:', btcBalance.vanilla);
console.log('Colored:', btcBalance.colored);
// Asset balance
const assetBalance = await wallet.getAssetBalance(asset.assetId);
console.log('Asset balance:', assetBalance);
Next Steps
- Learn about Installation for platform-specific setup
- Explore the Usage guide for detailed API documentation
- Check Troubleshooting if you encounter issues