Critical: Import polyfills at the very top of your index.js file, BEFORE importing your app or any other modules. The crypto module will fail to load if this order is wrong.
index.js
// These MUST be the first imports in your app entry pointimport 'react-native-get-random-values';import '@azure/core-asynciterator-polyfill';import { Buffer } from 'buffer';global.Buffer = Buffer;// Now import your appimport { AppRegistry } from 'react-native';import App from './App';import { name as appName } from './app.json';AppRegistry.registerComponent(appName, () => App);
4
Install Native Modules (iOS)
For iOS, you must install the native module dependencies. This step is required for bare React Native apps.
cd ios && pod install && cd ..
If you skip this step, you’ll see errors like Cannot read property 'decryptEcies' of null when initializing the wallet.
5
Setup Wallet
Create a wallet instance that will be used to interact with the Spark network.
A wallet requires either a mnemonic or raw seed for initialization. The initialize() function accepts both. If no input is given, it will auto-generate a mnemonic and return it.
A mnemonic is a human-readable encoding of your wallet’s seed. It’s a 12- or 24-word phrase from the BIP-39 wordlist, used to derive the cryptographic keys that control your wallet.