smartcontractsbigchaindb

Need help on bigchain db


I have two questions:

  1. Can I access all the blocks in bigchain somehow, block structure have no 'block height' attribute. We can access block by 'block id'. What I need to do is get data from all the blocks since Genesis.

  2. Bigchain db documentation says we can implement smart contact but there is nothing more than that, can anyone explain how can we do that.


Solution

  • Question 1

    There's no direct way to get blocks by 'block height' in BigchainDB, at least not today. There is a roundabout way to walk back through all blocks: First submit a valid transaction and wait until it's in a valid block. Then get the ID of the block that it's in. Then get the votes which voted on that block. Each vote includes the ID of the previous block. Get that previous block. And so on.

    To do all those things, you could use the HTTP API. You might also be able to use one of the drivers (e.g. the Python driver or the JavaScript driver).

    Question 2

    Standard BigchainDB doesn't support full-blown smart contracts akin to Ethereum, but it does support some functionality that smart contracts are commonly used to implement. In particular, an unspent output can be locked by a crypto-condition. It can only be unlocked by someone (or some group) with the ability to satisfy that crypto-condition. The supported crypto-conditions are things like: