https://github.com/oasislabs/react-native-web3c
https://github.com/oasislabs/react-native-web3c
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/oasislabs/react-native-web3c
- Owner: oasislabs
- License: other
- Created: 2019-03-18T18:28:53.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-22T18:37:03.000Z (over 6 years ago)
- Last Synced: 2025-01-26T19:17:15.274Z (12 months ago)
- Language: JavaScript
- Size: 1.31 MB
- Stars: 1
- Watchers: 26
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-native-web3c
react-native-web3c is a shim for [web3c.js](https://github.com/oasislabs/web3c.js) to make using web3c in react-native quick and easy.
## Usage
When including web3c.js in a react-native project, make sure to install and link the native randombytes, which is needed for the underlying crypto modules used by web3c.js.
```
yarn add react-native-web3c
yarn add react-native-randombytes
react-native link react-native-randombytes
```
After installing, you can use web3c.js in your react-native app like you would any other library.
If you find the Metro Bundler running out of memory, increase node's memory using the `--max-old-space-size=8192` flag.
## Persisting Key Manager Keys
When instantiating your `web3c` object, be sure to pass in the platform specific persistent storage you'd like to use. An in memory version of this interface is as follows:
```
class Storage {
constructor() {
this.db = new Map();
}
getItem(key) {
return this.db.get(key);
}
setItem(key, val) {
this.db.set(key, val);
}
}
```
Then when instantiating your web3c object, pass it in as part of options.
```
let web3c = new Web3c('https://web3.oasiscloud.io:443', undefined, {
storage: new Storage()
});
```
## Build
To build a new version of react-native-web3c, run
```
git clone https://github.com/oasislabs/react-native-web3c.git
yarn install
yarn webpack
```
Webpack will output the new index.js as a new version of web3c.js to be used in react-native.