React Native SDK
In this section, you'll learn how to build a React Native SDK using Mopro's native bindings. The process includes the following steps:
- Generate the binding using the Mopro CLI
 - Integrate the binding into a React Native Package
 - How to install the React Native SDK via npm
 - How to use the package
 - How to run an example app
 
Generate the bindings using the Mopro CLI
To get started with building Mopro bindings, refer to the Getting Started section. If you’d like to generate custom bindings for your own circuits or proving schemes, see the guide: Rust Setup for Android/iOS Bindings.
Then you will have a MoproAndroidBindings and/or MoproiOSBindings in the project directory.
Integrate the bindings into a React Native Package
- Clone the SDK template repository:
 
git clone https://github.com/zkmopro/mopro-react-native-package
- Replace the generated bindings:
 
- 
iOS: Replace the bindings directory
MoproiOSBindingswith the generated files in the following location:ios/MoproiOSBindings
 - 
Android: Replace the bindings directory
MoproAndroidBindings/uniffiandMoproAndroidBindings/jniLibswith your generated files in the following location:android/src/main/java/uniffiandroid/src/main/jniLibs
 
- Define the module API
 
- iOS:
- Define the native module API in 
ios/MoproReactNativePackageModule.swiftto match the React Native type. Please refer to Expo - Argument Types. 
 - Define the native module API in 
 - Android:
- Then define the native module API in 
android/src/main/java/expo/modules/moproreactnativepackage/MoproReactNativePackageModule.ktto match the React Native type. Please refer to Expo - Argument Types. 
 - Then define the native module API in 
 - React Native:
- Define React Native's module APIs to pass messages between React Native and your desired platforms.
 
 
How to install the React Native SDK via npm
Use a Node.js package manager in your React Native app to install dependencies. For example:
# npm
npm install https://github.com/zkmopro/mopro-react-native-package # Or change to your own URL
# yarn / pnpm
yarn add https://github.com/zkmopro/mopro-react-native-package # Or change to your own URL
Alternatively, you can manually add it to your package.json:
"dependencies": {
 "mopro-react-native-package": "github:zkmopro/mopro-react-native-package", // Or change to your own URL
}
How to use the package
Here is an example of how to integrate and use this package
import MoproReactNativePackage, { Result } from "mopro-react-native-package";
const circuitInputs = {
    a: [a],
    b: [b],
};
const proofResult: CircomProofResult =
    MoproReactNativePackage.generateCircomProof(
        ZKEY_PATH,
        JSON.stringify(circuitInputs)
    );
const isValid: boolean = await MoproReactNativePackage.verifyProof(
    ZKEY_PATH,
    parsedProofResult
);
console.log("Proof verification result:", isValid);
How to run an example app
- 
Open the example app that uses the defined react native package in the
example/foldercd example - 
Install the dependencies
npm install - 
Run on iOS simulator
npm run iosRun on iOS device
npm run ios:device - 
Run on Android emulator/device (if connected) Set the
ANDROID_HOMEenvironment variable.export ANDROID_HOME=~/Library/Android/sdk/Run on Android emulator/device (if connected)
npm run android