Approved content

The content below is provided by a partner.

microsoft/pxt-radio-blockchain 0.1.4 GitHub

radio-blockchain

A toy blockchain over radio

This is blockchain implementation is for educational purposes only.

Usage

The library starts as soon as the micro:bit starts. It uses the radio.

Add a block

The addBlock adds a block in the blockchain and broadcast its to peers.

blockchain.addBlock(0)

Read the values

Use the values block to get an array of number of the values stored in the chain, minus the genesis block.

blockchain.values()

Filtering values by micro:bit

You can also get the values contributed by a particular micro:bit using valuesFrom. The id block gives your micro:bit id.

blockchain.valuesFrom(blockchain.id())

Events

Events are raised when the chain is updated (when you received a new chain) or broadcasted.

blockchain.onEvent(BlockChainEvent.Update, () => {})

License

MIT

Supported targets

References

radio-blockchain=github:microsoft/pxt-radio-blockchain#v0.1.4