Skip to content

Latest commit

 

History

History
177 lines (120 loc) · 6.39 KB

README.md

File metadata and controls

177 lines (120 loc) · 6.39 KB
logo

MindLake Tutorial: Typescript SDK

A step-by-step cookbook for beginner to access Mind Lake !

📔 Table of Contents

🌟 0. Other Programming Languages

🌟 1. Install Or Upgrade Node If Needed

🌟 2. Get Examples

  1. Enter the following command in the terminal window to fetch the example code from github:
git clone https://github.com/mind-network/mind-lake-sdk-typescript.git
  1. Enter the path of example code:
cd mind-lake-sdk-typescript/examples
  1. Install depedency
npm install
  1. Check mind-lake-sdk depedency
npm info mind-lake-sdk version

An example of the output is:

1.0.2

🌟 3. Prepare myconfig.ts

  1. myconfig.ts contains the settings of parameters used in examples and use cases, you can copy myconfig_template.ts to the name myconfig.ts and modify it as per your requirement.
  2. myconfig.ts will need walletAddress and appKey.
  1. If you want to run the examples of quickStart, Use Case 1 and Use Case 2, you only need to fill out appKey.
  2. If you want to run Use Case 3, you need to fill out the wallets info for all of Alice, Bob and Charlie.
export const appKey = "YOUR_APP_KEY";
export const nodeUrl = "https://sdk.mindnetwork.xyz"; // or change to other node url
export const aliceWalletAddress = "Alice_Wallet_Address";
export const bobWalletAddress = "Bob_Wallet_Address";
export const charlieWalletAddress = "Charlie_Wallet_Address";

🌟 4. Execute the examples

You can execute the following commands to run the quickstart and use cases.

cd examples
npm run start

An example of the output is:

  App running at:
  - Local:   http://localhost:8002 (copied to clipboard)
  - Network: http://192.168.137.1:8002

By default use 8000 as port number. But will auto increase port number if 8000 is used. You may see 8000 in your side. The example bellow 8002. Use the port number shown in your terminal. Open a browser and visit http://localhost:8002

🎨 4.1 QuickStart

  1. First, you should create a test wallet for test.

image

image

  1. Click "Quick start with your MetaMask" and you will see the logs while login with your MetaMask wallet

image

image

🎨 4.2 Use Case 1: Single User with Structured Data

  1. Open a browser and visit http://localhost:8002/use_case_1
  2. Click "Test case one with your MetaMask" and you will see the logs while executing Use Case 1.

image

🎨 4.3 Use Case 2: Single User with Unstructured Data

  1. Open a browser and visit http://localhost:8002/use_case_2
  2. Click "Test case two with your MetaMask" and you will see the logs while executing Use Case 2

image

🎨 4.4 Use Case 3: Multi Users with Permission Sharing

  1. You will need 3 wallets for Use Case 3: Alice, Bob, Charlie We show how to create a wallet for Alice for testing purpose.

image

image

Using the same way to create wallet for Bob and Charlie

Copy Alice,Bob,Charlie' wallet address into myconfig.ts to update aliceWalletAddress bobWalletAddress charlieWalletAddress

Note During testing period, please make you have all wallet address are registered in into whitelist: https://sites.google.com/mindnetwork.xyz/mindnetwork/alpha-test. Be more specific, please ensure your Alice, Bob and Charlie are registered and approved. Otherwise, you may experience the error on sharing.

  1. Open a browser and visit http://localhost:8002/use_case_3

image

  1. Switch to Alice's wallet and perform actions as Alice

image

image

Click "Insert Alice Data And Share To Charlie"

image

Wait until "insert data done" appears which means data insertion is completely.

  1. Switch to BOb's wallet and performa actions as Bob

image

image

Click "Insert Bob Data And Share To Charlie"

image

Wait until "insert data done" appears which means data insertion is completely.

  1. Switch to Charlie's wallet and performa actions as Charlie

image

image

Click "Charlie Select Data And Decrypt Data"

image

  1. Final output quick view

image