1.5.0 • Published 1 year ago

project-afael-hlw v1.5.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

HLW

HLW is a decentralized key-value database on Arweave network, powered by Warp-Contracts.

Setup

Setup has couple steps which you need to stick to them.

Installation

Download the repo,

git clone https://github.com/firstbatchxyz/HollowDB.git

Install it with yarn,

cd HollowDB
yarn

Supply Wallet

You need to supply arweave wallet jwk to the repo with some amount of AR in them.

Name your wallet as wallet-main.json and put it under the config/wallet as seen in the below.

/
├── config/
|   ├── contract/
|   └── wallet/
|       └── wallet-main.json
├── example
├── sdk
.
.

Deploy Contracts

You need to build and deploy the parent and bucket contracts.

Run the following commands at the root of the repo,

yarn build
yarn deploy parent
yarn deploy bucket

yarn build command will build the contracts under /dist folder.

yarn deploy will deploy the contracts while saving the deploy results (contractTxId and srcTxId) under the /config/contract folder.

Utils

Repo is packed with various utilities.

Contract Utils

Deploy

Wallet Utils

Read Wallet

Bundlr Utils

Fund, Balance, Upload

Development

See examples for getting started.

SDK Methods

Crating a new SDK Object,

import { SDK } from '../sdk/index.js';
import { getWallet } from '../src/util/getWallet.js';
import { getConfig } from '../src/util/getConfig.js';

const jwk = await getWallet('wallet-main.json');
const parentData = await getConfig('parent');

const db = new SDK(jwk, parentData.contractTxId);

Below are the sdk methods.

setBucketSrc

Saves the SourceTxId of the previously deployed bucket contract in the parent contract state. Future bucket contract deployments will read this data from parent state, this improves ease of use while eliminating the chance of mixing bucket contract versions while deploying the bucket contracts.

await db.setBucketSrc('bucket-src-tx-id');

You can find the srcTxId of the previously deployed bucket contract under the /config/contract/bucket.json or you can use config utility `getConfig()

const bucketData = await getConfig('bucket');
const myBucketSource = bucketData.srcTxId;

getBucketSrc

Returns the Bucket srcTxId from parent contract state.

const myBucketSource = await db.getBucketSrc();

putOne

Puts one user into the DB.

//HollowDB expects users in the following format
const usr = {
  fb_id: '1234567890123456789012345678901234567890123456789012345678901234',
  merkle_root: '1234567890123456789012345678901234567890123456789012345678901234',
  usr_vector: [0.123456, 0.123456, ...0.123456]
};

await db.putOne(usr);

putMany

getOne

Returns the user from the database with the given id.

const res = await db.getOne(user.fb_id);

getMany

getAll

1.5.0

1 year ago

1.4.5

1 year ago

1.4.4

1 year ago

1.4.3

1 year ago

1.4.2

1 year ago

1.4.1

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago