npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

babbage-kvstore

v1.2.36

Published

Set and get keys and Values©

Downloads

124

Readme

Babbage-KVStore

A flexible and decentralized Key-Value storage and retrieval system, designed and engineered around the feature-rich and versatile Bitcoin SV (BSV).

npm version

Table Of Contents

Introduction

Babbage KVStore provides robust key-value storage functionality for your applications that leverages the power of Bitcoin SV's blockchain technology. By treating Bitcoin transactions (specifically UTXOs or Unspent Transaction Outputs) as your value store, you can create highly-distributed and verifiably-secure data storage for your application.

Installation

Simply use npm to include Babbage KVStore in your project:

npm install babbage-kvstore

Usage

Setting and Getting values

You can easily set up and utilize a key-value (KV) structure with Babbage. The set method takes in a key and a value, which are both strings. The get method retrieves the value associated with a key. Here is an example:

const { get, set } = require('babbage-kvstore');

// Set a value
set('Hello', 'World');

// Retrieve a value
console.log(get('Hello')); // Outputs: 'World'

Removing a Value

The remove method is used to delete a value in your KV store. All you need is the key:

const { remove } = require('babbage-kvstore');

// Remove a value
remove('Hello');

Retrieving Previous Values

getWithHistory lets you view previous versions of a value, allowing for an auditable log. This can be very powerful in several auditing and data tracking scenarios:

const { getWithHistory } = require('babbage-kvstore');

// Retrieve a value with history
console.log(getWithHistory('Hello')); // Outputs: entire history of 'Hello'

Configuration

None of these values are required, but you can use them to customize and greatly extend the behavior of KVStore.

Name | Description | Default Value ----------------------|---------------------------|--------------------- actionDescription | Description for the Action that sets a value | Set a value for (key) outputDescription | Description for the transaction output (line item) that represents a new value | none spendingDescription | Description for the consumption of a previous value | none confederacyHost | URL to the overlay network node that tracks the UTXOs you want to interact with | 'https://confederacy.babbage.systems' topics | Overlay network node topics where UTXOs are stored and retrieved | ['kvstore'] protocolID | Sets the universe in wihch your keys and values are stored. Items in one universe can only be accessed in the same universe. | [0, 'kvstore'] tokenAmount | Sets the number of satoshis in each KVStore UTXO | 1000 authriteConfig | Parameters used to construct the Authrite client used to communicate with the overlay network node | undefined counterparty | Allows the sharing and transfer of tokens between users (advanced) | undefined receiveFromCounterparty | Move the token sent from the counterparty to self | false sendToCounterparty | Move the token owned by self to the counterparty | false viewpoint | Allows access to data repositories outside of one's own control. The viewpoint must be the identity public key of the repository owner. By default, only data from your own local viewpoint is accessible. | localToSelf doubleSpendMaxAttempts | The max number of times it should reattempt an action if a double spend error is detected. | 5 attemptCounter | Keeps track of the current retry attempts if a double spend error is detected. | 0

Applications and Use Cases

Due to its distributed, secure, and robust nature, Babbage KVStore can be used in various scenarios. A few key examples include:

  • Decentralized applications:
    • Enhanced user security
    • Non-fungible tokens (NFTs)
    • On-chain social media
    • Data provenance tracking
  • Auditing systems: With the use of the getWithHistory function, you can implement auditable logging and tracking systems.
  • Secure system settings: Store secure system environment settings.
  • Gaming: Keep track of game states and history.

API

Table of Contents

get

Gets a value from the store.

Parameters

  • key String The key for the value to get
  • defaultValue String The value returned when no token is found (optional, default undefined)
  • config Object The config object (see the config section) (optional, default {})

Returns Promise<String> The value from the store

getWithHistory

Gets a value from the store with history of token

Parameters

  • key String The key for the value to get
  • defaultValue String The value returned when no token is found (optional, default undefined)
  • config object The config object (see the config section) (optional, default {})

Returns Promise<object> The value from the store and history of the token

set

Sets a new value in the store, overwriting any existing value.

Parameters

  • key String The key for the value to set
  • value String The value to store
  • config Object The config object (see the config section) (optional, default {})

Returns Promise Promise that resolves when the value has been stored

remove

Deletes a value from the store.

Parameters

  • key String The key for the value to remove
  • config Object The config object (see the config section) (optional, default {})

Returns Promise Promise that resolves when the value has been deleted

License

The license for the code in this repository is the Open BSV License.