@cybavo/react-native-wallet-service
React-native version of CYBAVO Wallet SDK. Learn more on our website: https://www.cybavo.com/wallet-app-sdk/Institutional-grade security for your customers
Protect your customers’ wallets with the same robust technology we use to protect the most important cryptocurrency exchanges. CYBAVO Wallet App SDK allows you to develop your own cryptocurrency wallet, backed by CYBAVO private key protection technology.Mobile SDK
Use CYBAVO Wallet App SDK to easily develop secure wallets for your users without having to code any cryptography on your side. Our SDK allows you to perform the most common operations, such as creating a wallet, querying balances and executing cryptocurrency payments.Secure key management system
Key management is the most critical part of cryptocurrency storage. CYBAVO Wallet App SDK makes our robust private key storage system available to all of your users. Our unique encryption scheme and a shared responsibility model offers top notch protection for your customer’s keys.CYBAVO Security Cloud
Cryptocurrency transactions performed by wallets developed with CYBAVO Wallet App SDK will be shielded by our Security Cloud, ensuring their integrity.Complete solution for cryptocurrency wallets
Cost saving
Leverage your in-house developing team and develop mobile cryptocurrency apps without compromising on security.Fast development
Quickly and easily develop cryptocurrency applications using mobile native languages, without having to worry about cryptographic code.Full Node maintenance
Leverage CYBAVO Wallet App SDK infrastructure and avoid maintaining a full node for your application.Feel free to contact us for product inquiries or mail us: info@cybavo.com
CYBAVO
A group of cybersecurity experts making crypto-currency wallet secure and usable for your daily business operation.We provide VAULT, wallet, ledger service for cryptocurrency. Trusted by many exchanges and stable-coin ico teams, please feel free to contact us when your company or business need any help in cryptocurrency operation.
Getting started
$ npm install @cybavo/react-native-wallet-service --save
- Polyfill NodeJS modules for React-Native
```
$ yarn add rn-nodeify
$ rn-nodeify --install --hack
```
- unmark
require('crypto')
inshim.js
Mostly automatic installation
$ react-native link @cybavo/react-native-wallet-service
Manual installation
iOS
- Append this line in
Podfile
:
```
pod 'CybavoWalletService', :path => "../node_modules/@cybavo/react-native-wallet-service/ios/CybavoWalletService.podspec"
```
- Go to ./ios, run ``
pod install
`` to install all dependencies. - Open ``
./ios/{{your project}}.xcworkspace
`` in XCode - In XCode, run your project (
Cmd+R
)<
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.cybavo.reactnative.wallet.service.CybavoWalletServicePackage;
to the imports at the top of the file - Add
new CybavoWalletServicePackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:
```
include ':@cybavo/react-native-wallet-service'
project(':@cybavo/react-native-wallet-service').projectDir = new File(rootProject.projectDir, '../node_modules/@cybavo/react-native-wallet-service/android')
```
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:
```
compile project(':@cybavo/react-native-wallet-service')
```
Usage
```javascript import { WalletSdk, Auth, Wallets } from "@cybavo/react-native-wallet-service"; ```WalletConnect
CYBAVO Wallet App SDK has integrated WalletConnect to support wallet apps connecting with Dapps (Web3 Apps).- Following code snippet is the simple usage of how to new a session, approve session request and approve call request
For further technical specification, please refer to [WalletConnect's official document](https://docs.walletconnect.org/tech-spec)
```javascript
import { WalletConnectSdk } from "@cybavo/react-native-wallet-service";
const { WalletConnectManager, WalletConnectHelper } = WalletConnectSdk;
// Establish session, then the callback will receive session request
let connectorWrapper = WalletConnectManager.newSession(
walletConnectUri,
walletAddress,
walletId,
walletClientMeta,
(error, payload) => {
sessionRequestCallback(connectorWrapper.getConnector().peerId, error, payload);
}
);
let sessionRequestCallback = (peerId, error, payload) => {
//approve session, then pass the listeners to receive call request and disconnect event
WalletConnectManager.approveSession(
peerId,
{
accounts: [walletAddress],
chainId: 1, //main net
},
(error: any, payload: any) => {
callRequestListener(peerId, error, payload);
},
disconnectListener
)
}
let callRequestListener = (peerId, error: any, payload: any) => {
WalletConnectManager.approveRequest(peerId, response).then(() => {})
}
let disconnectListener = (error: any, payload: any) => {}
```
- API to support handling call request
[Here](https://docs.walletconnect.org/json-rpc-api-methods/ethereum) defined methods that wallet app should implement.
We also provided API to handle corresponding methods:
* personal_sign, eth_sign
```javascript
let message = payload.params[0];
let result = await Wallets.walletConnectSignMessage(
walletId,
convertHexToUtf8(message),
pinSecret
);
```
* eth_sendTransaction
```javascript
let tx = payload.params[0];
// 1. sign transaction
let result = await Wallets.walletConnectSignTransaction(
walletId,
tx,
transactionFee,
pinSecret
);
// 2. send signed transaction
let sendResult = await Wallets.walletConnectSendSignedTransaction(
walletId,
result.signedTx
);
// return TXID as approve response to the Dapp
let response = { result: sendResult.txid, id: payload.id };
await WalletConnectManager.approveRequest(peerId, response);
```
* eth_signTypedData
```javascript
let message = payload.params[1];
let result = await Wallets.walletConnectSignTypedData(
walletId,
message,
pinSecret
);
let response = { result: '0x' + result.signedTx, id: payload.id };
await WalletConnectManager.approveRequest(peerId, response);
```
* eth_sendRawTransaction
```javascript
let signedTx = params[0];
let sendResult = await Wallets.walletConnectSendSignedTransaction(
walletId,
signedTx
);
// return TXID as approve response to the Dapp
let response = { result: sendResult.txid, id: payload.id };
await WalletConnectManager.approveRequest(peerId, response);
```
* eth_signTransaction
```javascript
let tx = payload.params[0];
let result = await Wallets.walletConnectSignTransaction(
walletId,
tx,
transactionFee,
pinSecret
);
let response = { result: result.signedTx, id: payload.id };
await WalletConnectManager.approveRequest(peerId, response);
```
- Other supportive API
* Wallets.walletConnectSync
Check if there're any changes after transactions committed through `Wallets.walletConnectSendSignedTransaction` or `Wallets.sendSignedTx` and perform the updates.
* Wallets.getWalletConnectApiHistory
All walletconnect related API will be logged as ApiHistoryItem with vary API Names. Use `Wallets.getWalletConnectApiHistory` to fetch API histories.
* Wallets.cancelWalletConnectTransaction
Use `Wallets.cancelWalletConnectTransaction` to cancel a pending transaction which sent through `Wallets.walletConnectSendSignedTransaction`.
It's required a higher transaction fee (1.1 times) to replace the original transaction with 0 amount.
Check our sample app on GitHub:
https://github.com/CYBAVO/react-nativewalletsdksampleRefer to documents for details of extra parameters.