ResVault is a chrome extension that serves as a wallet for ResilientDB. The wallet allows you to commit and retrieve data from ResilientDB and provides user account creation and deletion. It communicates with ResilientDB using the ResilientDB GraphQL server and enables transaction logging.
Prerequisites
Setup Python3.10
Ensure you have Python3.10, otherwise download it and set it up as default.
- Check with:
python3 –version
Setup ResilientDB
- You will need to clone the ResilientDB repo to get started:
git clone https://github.com/resilientdb/resilientdb.git
- Then navigate inside the ResilientDB directory:
cd resilientdb
- Install dependencies:
sh INSTALL.sh
- Run ResilientDB KV Service (this may take a few minutes for the first time):
./service/tools/kv/server_tools/start_kv_service.sh
Setup Crow HTTP server, SDK, and GraphQL server
- You will need to clone the ResilientDB GraphQL repo to get started:
git clone https://github.com/ResilientApp/ResilientDB-GraphQL.git
- Then navigate inside the ResilientDBGraphQL directory:
cd ResilientDB-GraphQL
- Install the Crow dependencies:
sudo apt update sudo apt install build-essential sudo apt install python3.10-dev sudo apt install apt-transport-https curl gnupg
- Build Crow HTTP server (this may take a few minutes for the first time):
bazel build service/http_server:crow_service_main
- Start the Crow HTTP server:
bazel-bin/service/http_server/crow_service_main service/tools/config/interface/client.config service/http_server/server_config.config
- Create virtual environment for the Python SDK:
python3 -m venv venv –without-pip
- Activate the virtual environment:
source venv/bin/activate
- Install pip in the virtual environment for the Python dependencies:
curl https://bootstrap.pypa.io/get-pip.py | python
- Install the Python dependencies:
pip install -r requirements.txt
- Start the GraphQL server. (The GraphQL is implemented based on our Python SDK. For more information about the Python SDK, please refer to our SDK blog)
python3 app.py
Setup Wallet
Build from source code
You can generate the wallet build using the ResVault source code. To do this:
-
Download NodeJS from here and ensure that it’s added to PATH.
- Clone the ResVault repo to get started:
git clone https://github.com/ResilientApp/ResVault.git
- Then navigate inside the ResVault directory:
cd ResVault
- Install the dependencies.
npm install
- Build the wallet.
npm run build
- You will see the following message if build was successful:
The build folder is ready to be deployed. You may serve it with a static server: serve -s build Find out more about deployment here: https://cra.link/deployment
- The build will now be available in
build
directory inside the ResVault directory.
Add build to chrome
Once you have generated the build:
-
Open chrome and navigate to
chrome://extensions/
-
Make sure developer mode is enabled using the toggle button.
-
Finally, load the extension by clicking on load unpacked button and then select the
build
folder that was created in the previous step. -
Now you can open the wallet from the extension button and start using it!
Add release to chrome
Alternatively, you can use the release from the ResVault repo instead of generating your own build. To do this:
-
Download the latest build.zip from here.
-
Extract the contents in a new directory.
-
Open chrome and navigate to
chrome://extensions/
-
Make sure developer mode is enabled using the toggle button.
-
Finally, load the extension by clicking on load unpacked button and then select the directory where you extracted the contents previously.
-
Now you can open the wallet from the extension button and start using it!
Usage
In order to use the ResVault chrome extension ensure that you have KV service, Crow HTTP server, and ResilientDB GraphQL server running in the terminal windows:
-
One terminal window should run:
bazel-bin/service/http_server/crow_service_main service/tools/config/interface/service.config service/http_server/server_config.config
after navigating inside the ResilientDB GraphQL directory. -
The other terminal window should run:
./service/tools/kv/server_tools/start_kv_service.sh
after navigating inside the ResilientDB directory. -
The final terminal window should run:
python3 app.py
after navigating inside the ResilientDB GraphQL directory.
GraphQL playground
Additionally, you can also experiment with the deployed instance of ResilientDB on https://cloud.resilientdb.com/graphql
Example Mutations
- Generate Keys
mutation { generateKeys { publicKey privateKey } }
- Set Transaction
mutation { postTransaction(data: { operation: "CREATE" amount: 50 signerPublicKey: "8fPAqJvAFAkqGs8GdmDDrkHyR7hHsscVjes39TVVfN54" signerPrivateKey: "5R4ER6smR6c6fsWt3unPqP6Rhjepbn82Us7hoSj5ZYCc" recipientPublicKey: "ECJksQuF9UWi3DPCYvQqJPjF6BqSbXrnDiXUjdiVvkyH" asset: """{ "data": { "time": 1690881023169 }, }""" }) { id } }
- Update Transaction
mutation { updateTransaction(data:{ id: "a534f09b6983492f05c19c8a35024ca7109511f2057ae54b18b6bfd1b6d13af6" operation: "" amount: 70 signerPublicKey: "8fPAqJvAFAkqGs8GdmDDrkHyR7hHsscVjes39TVVfN54" signerPrivateKey: "5R4ER6smR6c6fsWt3unPqP6Rhjepbn82Us7hoSj5ZYCc" recipientPublicKey: "ECJksQuF9UWi3DPCYvQqJPjF6BqSbXrnDiXUjdiVvkyH" asset: "" }) { id version amount metadata operation asset publicKey uri type } }
- Update Multiple Transactions
mutation { updateMultipleTransaction(data:[{ id: "a534f09b6983492f05c19c8a35024ca7109511f2057ae54b18b6bfd1b6d13af6" signerPublicKey: "8fPAqJvAFAkqGs8GdmDDrkHyR7hHsscVjes39TVVfN54" signerPrivateKey: "5R4ER6smR6c6fsWt3unPqP6Rhjepbn82Us7hoSj5ZYCc" operation: "" amount: 40 asset: "" recipientPublicKey: "" }, { id: "b8e5173634eb0e0ce3dae30fc6b2a97987623e48231524aaf90a6e028ff048ee" signerPublicKey: "8fPAqJvAFAkqGs8GdmDDrkHyR7hHsscVjes39TVVfN54" signerPrivateKey: "5R4ER6smR6c6fsWt3unPqP6Rhjepbn82Us7hoSj5ZYCc" operation: "" amount: 54 asset: "" recipientPublicKey: ""}]) { id version amount metadata operation asset publicKey uri type } }
Example Queries
- Get Transaction
query {getTransaction(id: "a534f09b6983492f05c19c8a35024ca7109511f2057ae54b18b6bfd1b6d13af6") { id version amount metadata operation asset publicKey uri type signerPublicKey }}
- Get Filtered Transactions
query { getFilteredTransactions(filter: { ownerPublicKey: "" recipientPublicKey: "" }) { id version amount metadata operation asset publicKey uri type } }
Demo video
Now you can use ResVault as shown in the video:
The next tutorial will elaborate on how to develop web applications to communicate with the wallet.