Skip to content

⭐ Helper library for BigChainDB (Blockchain Database) tasks ⭐

License

Notifications You must be signed in to change notification settings

RyanDsilva/easy-bigchain

Repository files navigation

⭐️ Easy Bigchain ⭐️

Stars Issues MIT

Helper library for BigChainDB tasks. Blockchain Database now with a high level abstracted API. Blockchain, accessible to all!

HitCount


Installation 💻

$ npm install easy-bigchain --save

Usage 👨‍💻

import bigchain from 'easy-bigchain'

1. Connect to BigChainDB

const connection = bigchain.connect(CONNECTION_STRING)
// Default == https://test.bigchaindb.com/api/v1/

2. Generate KeyPairs for Users

const user = bigchain.generateKeypair()

OR

const user = bigchain.generateKeypair(SEED_PHRASE)

3. Create Asset

bigchain.createAsset(CONNECTION_OBJECT, ASSET, METADATA, USER, function(
  transaction
) {
  // execute code
})
  • CONNECTION OBJECT : Object returned from the connect() function call
  • ASSET : The main data object (immutable)
  • METADATA : Additonal Information to be stored
  • USER : Object returned from the generateKeypair() function call

4. Transfer Asset

bigchain.transferAsset(
  CONNECTION_OBJECT
  TRANSACTION,
  METADATA,
  CURRENT_OWNER,
  NEW_OWNER,
  function(transaction) {
    // execute code
  }
)
  • CONNECTION OBJECT : Object returned from the connect() function call
  • TRANSACTION : The original Transaction from where the asset is to be transferred
  • METADATA: Additonal Information to be stored
  • CURRENT OWNER and NEW OWNER are objects returned from the generateKeypair() function call

Due to some unexpected behaviour of the getTransaction() function, I have made use of the entire transaction itself. Not efficient but works till that issue is fixed.


Contributing ✨

Please send a Pull Request with appropriate documentation and I would be more than happy to merge it! 😄