![image.png](https://files.peakd.com/file/peakd-hive/krios003/23xVkxPiZ3K6xQYjXgi3mA2wkpSw3s3CAjQjnE5PJD2d2re1xGR7raKfuzxYwrjM9qhrh.png) (Photo generated with PeakD image generator) I initially needed a tool to interact with the blockchain and retrieve various HBD-related operations for my practice project. # HBD Wallet I've been working on a website where users can manage their HBD savings and perform various transactions related to HBD. This is essentially a practice project as I am studying the Next.js full-stack framework. Here's my latest progress: ![image.png](https://files.peakd.com/file/peakd-hive/krios003/23uQfqE4wzPk7gAfaYfkSG1cbXzzMPzd9Z3EnfCtqNM7bNz8Vqr416uU187VcU36F8NKS.png) It currently displays a dashboard of balances, deposits, interst, and a chart of accumulated HBD and deposits over time. The website isn't public yet! # HBD Repo To build this website, I need to rely heavily on blockchain historical data. To make things easier, clean, and easy to maintain, I created [HBD Repo](https://github.com/carlodizon03/hbd-sql). It is initially using [HiveSQL](https://hivesql.io/) however, I just discovered yesterday that it isn't funded anymore and will not be free to use. Mannnn, I just can't afford a 5HBD/day. Now, I just migrated it to use [HafSQL](https://mahdiyari.gitlab.io/hafsql/). Which works similarly with some differences in tables schema. If you are like me who is working on a project involving HBD, feel free to contribute to my code and suggest features. The source code is here: [sauce](https://github.com/carlodizon03/hbd-sql) ## How to use It is written in typescript btw, so I it requires you to be familiar to it. Optionally, you have to install the Postgres library ``` npm install pg ``` You need the HafSQL public credentials, thanks to @mahdiyari : ``` const poolConfig: PoolConfig = { user: `hafsql_public`, host: `hafsql-sql.mahdiyari.info`, database: `haf_block_log`, password: `hafsql_public`, port: 5432, }; ``` Then you are good to go with this example: dont forget to change 'your-username' ``` import { PoolConfig } from 'pg'; import { HBDRepo } from 'hbd-sql/dist'; const poolConfig: PoolConfig = { user: `hafsql_public`, host: `hafsql-sql.mahdiyari.info`, database: `haf_block_log`, password: `hafsql_public`, port: 5432, }; async function main() { try { // Get the singleton instance of HBDRepo const repo = HBDRepo.getInstance(poolConfig); console.log('Deposits'); const deposits = await repo.deposits('your-username'); console.log('Deposits:', deposits); console.log('Withdrawals'); const withdrawals = await repo.withdrawals('your-username'); console.log('Withdrawals:', withdrawals); console.log('Total Deposit'); const totalDeposit = await repo.totalDeposit('your-username'); console.log('Total Deposit:', totalDeposit); console.log('Total Withdrawals'); const totalWithdrawal = await repo.totalWithdrawal('your-username'); console.log('Total Withdrawal:', totalWithdrawal); console.log('Total Interest'); const totalInterest = await repo.totalInterest('your-username'); console.log('Total Interest:', totalInterest); console.log('Interest Rate'); const interestRate = await repo.interestRate(); console.log('Interest Rate:', interestRate ? 'success' : 'failed'); console.log('Savings Details'); const savingsDetails = await repo.savingsDetails('your-username'); console.log('Savings Details:', savingsDetails); console.log('Interest Payments'); const interestPayments = await repo.interestPayments('your-username'); console.log({ interestPayments }); } catch (error) { console.error('An error occurred:', error); } } main(); ``` Let me know what functions would be useful for you, I would be happy to include it!