Coinmonks
Published in

Coinmonks

BigchainDB, a database on blockchain steroids

BigchainDB shares the main benefits of blockchain technology and distributed databases.
  • CREATE transactions generate a new asset in the system (as a JSON document in MongoDB) with two types of information in it: asset information, which is immutable and can’t be modified once the asset is created; and metadata, which can be modified through subsequent TRANSFER transactions.
  • TRANSFER transactions allow the transfer of ownership of an asset, or the modification of the metadata. The only one entitled to perform this transaction over an asset is its owner. These transactions use as input an unused output of the asset, generating as a result a new output with the corresponding modifications (changes in its ownership or metadata). As advanced above, an asset output can not be used twice as input of a transfer transaction.
git clone https://github.com/bigchaindb/bigchaindb.git
cd bigchaindb
make run
// Require JS driver
const
driver = require('bigchaindb-driver')
// Create an identity key pair
const
myIdentity = new driver.Ed25519Keypair()
//Connect to the BigchainDB test network
const
conn = new driver.Connection('https://test.bigchaindb.com/api/v1/')
//Connect or our local infrastructure
const
conn = new driver.Connection('http://localhost:9984/api/v1/')
// Create a new CREATE transaction (new output)
const
tx = driver.Transaction.makeCreateTransaction(
{ name: 'My Asset', immutable_attr1: "bla bla" },{ metadata1: "here goes", metadata2: "my metadata attributes"},[ driver.Transaction.makeOutput(driver.Transaction.makeEd25519Condition(myIdentity.publicKey))],alice.publicKey)//Sign the transaction
const
txSigned = driver.Transaction.signTransaction(tx, myIdentity.privateKey)
//Send it to the network
conn.postTransactionCommit(txSigned)
//Search asset
conn.searchAssets('My Asset').then(assets => console.log('Found assets with name My asset:', assets))
//Search metadata
conn.searchMetadata('here goes').then(metadata => console.log('Found asset metadata with metadata1 here goes:', metadata))
// Require JS driver
const
driver = require('bigchaindb-driver')
// Create an identity key pair
const
myIdentity = new driver.Ed25519Keypair()
//Connect to the BigchainDB test network
const
conn = new driver.Connection('https://test.bigchaindb.com/api/v1/')
// Create a new transaction
const
tx = driver.Transaction.makeCreateTransaction(
{ name: 'My Asset', immutable_attr1: "bla bla" },{ metadata1: "here goes", metadata2: "my metadata attributes"},[ driver.Transaction.makeOutput(driver.Transaction.makeEd25519Condition(myIdentity.publicKey))],alice.publicKey)//Sign the transaction
const
txSigned = driver.Transaction.signTransaction(tx, myIdentity.privateKey)
//Send it to the network
conn.postTransactionCommit(txSigned)
//Search asset
conn.searchAssets('My Asset').then(assets => console.log('Found assets with name My asset:', assets))
//Search metadata
conn.searchMetadata('here goes').then(metadata => console.log('Found asset metadata with metadata1 here goes:', metadata))

Get Best Software Deals Directly In Your Inbox

Click to read today’s top story

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store