1.2.27 • Published 1 day ago

babbage-kvstore v1.2.27

Weekly downloads
-
License
Open BSV License
Repository
github
Last release
1 day ago

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.

NameDescriptionDefault Value
actionDescriptionDescription for the Action that sets a valueSet a value for (key)
outputDescriptionDescription for the transaction output (line item) that represents a new valuenone
spendingDescriptionDescription for the consumption of a previous valuenone
confederacyHostURL to the overlay network node that tracks the UTXOs you want to interact with'https://confederacy.babbage.systems'
topicsOverlay network node topics where UTXOs are stored and retrieved['kvstore']
protocolIDSets the universe in wihch your keys and values are stored. Items in one universe can only be accessed in the same universe.[0, 'kvstore']
tokenAmountSets the number of satoshis in each KVStore UTXO1000
authriteConfigParameters used to construct the Authrite client used to communicate with the overlay network nodeundefined
counterpartyAllows the sharing and transfer of tokens between users (advanced)undefined
receiveFromCounterpartyMove the token sent from the counterparty to selffalse
sendToCounterpartyMove the token owned by self to the counterpartyfalse
viewpointAllows 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
doubleSpendMaxAttemptsThe max number of times it should reattempt an action if a double spend error is detected.5
attemptCounterKeeps 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](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/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](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/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.

1.2.27

1 day ago

1.2.25

5 days ago

1.2.26

5 days ago

1.2.24

7 days ago

1.2.23

14 days ago

1.2.22

15 days ago

1.2.20

27 days ago

1.2.21

27 days ago

1.2.19

28 days ago

1.2.16

30 days ago

1.2.17

30 days ago

1.2.18

29 days ago

1.2.14

1 month ago

1.2.15

1 month ago

1.2.13

1 month ago

1.2.12

1 month ago

1.2.11

2 months ago

1.2.10

2 months ago

1.2.8

2 months ago

1.2.9

2 months ago

1.2.7

2 months ago

1.2.6

2 months ago

1.2.5

2 months ago

1.2.4

2 months ago

1.2.0

2 months ago

1.2.3

2 months ago

1.2.2

2 months ago

1.2.1

2 months ago

1.1.58

2 months ago

1.1.56

2 months ago

1.1.57

2 months ago

1.1.55

3 months ago

1.1.54

3 months ago

1.1.53

3 months ago

1.1.52

3 months ago

1.1.51

3 months ago

1.1.50

3 months ago

1.1.49

3 months ago

1.1.48

3 months ago

1.1.47

3 months ago

1.1.46

3 months ago

1.1.45

3 months ago

1.1.44

3 months ago

1.1.43

3 months ago

1.1.42

3 months ago

1.1.41

4 months ago

1.1.40

4 months ago

1.1.39

4 months ago

1.1.38

4 months ago

1.1.37

4 months ago

1.1.36

5 months ago

1.1.35

5 months ago

1.1.34

5 months ago

1.1.33

5 months ago

1.1.32

5 months ago

1.1.31

5 months ago

1.1.29

5 months ago

1.1.30

5 months ago

1.1.28

5 months ago

1.1.27

5 months ago

1.1.26

5 months ago

1.1.25

5 months ago

1.1.24

5 months ago

1.1.11

10 months ago

1.1.16

9 months ago

1.1.15

9 months ago

1.1.14

9 months ago

1.1.13

9 months ago

1.1.18

8 months ago

1.1.17

8 months ago

1.1.23

6 months ago

1.1.22

6 months ago

1.1.21

6 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.1.9

11 months ago

1.1.8

11 months ago

1.1.7

11 months ago

1.1.6

11 months ago

1.1.5

11 months ago

1.1.4

11 months ago

1.1.3

11 months ago

1.1.2

11 months ago

1.1.10

11 months ago

1.0.1

1 year ago

1.0.0

2 years ago