Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
react-native-mnemonic-key
Advanced tools
Native Android and iOS implementation of MnemonicKey for React Native
This library provides RNMnemonicKey
, a native Android and iOS implementation of Terra.js's MnemonicKey
, made available for React Native. This significantly improves performance and compatibility in mobile apps.
Install to your React Native app's package.json
:
yarn add react-native-mnemonic-key
You may need to set multiDexEnabled true
in your Android app's build.gradle
:
// android/app/build.gradle
android {
...
defaultConfig {
applicationId "com.example.reactnativemnemonickey"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true // ADD THIS LINE
}
}
You may need to modify your iOS app's Podfile
to enable Modular Headers for TrezorCrypto
.
pod 'TrezorCrypto', :modular_headers => true # Need to add modular headers
A full example demo app is available inside /example
.
The usage is nearly identical to Terra.js's MnemonicKey
, with the exception that RNMnemonicKey
cannot be instantiated with new
. You must use the static factory method RNMnemonicKey.create
, which returns a Promise<RNMnemonicKey>
.
// NOT ALLOWED!
// new RNMnemonicKey({ ...options })
// RIGHT WAY
RNMnemonicKey.create({ ...options }).then((rnmk) => terra.wallet(rnmk));
For your convenience, a full example demo app is provided as a reference inside /example
.
yarn example ios
- run iOS demoyarn example android
- run Android demoimport * as React from 'react';
import { StyleSheet, View, Text } from 'react-native';
import { RNMnemonicKey } from 'react-native-mnemonic-key';
export default function App() {
const [result, setResult] = React.useState<RNMnemonicKey | undefined>();
React.useEffect(() => {
RNMnemonicKey.create({
mnemonic:
'satisfy adjust timber high purchase tuition stool faith fine install that you unaware feed domain license impose boss human eager hat rent enjoy dawn',
coinType: 118,
account: 5,
index: 32,
}).then(setResult);
}, []);
return (
<View style={styles.container}>
<Text>Address: {result?.accAddress}</Text>
<Text>ValAddress: {result?.valAddress}</Text>
<Text>Mnemonic: {result?.mnemonic}</Text>
<Text>PrivateKey: {result?.privateKey.toString('hex')}</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
box: {
width: 60,
height: 60,
marginVertical: 20,
},
});
This software is licensed under the MIT license. See LICENSE for full disclosure.
© 2021 Terraform Labs, PTE.
FAQs
Native Android and iOS implementation of MnemonicKey for React Native
The npm package react-native-mnemonic-key receives a total of 20 weekly downloads. As such, react-native-mnemonic-key popularity was classified as not popular.
We found that react-native-mnemonic-key demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.