https://github.com/microsoft/pxt-radio-blockchain
A toy blockchain for the micro:bit radio and MakeCode
https://github.com/microsoft/pxt-radio-blockchain
makecode
Last synced: 12 days ago
JSON representation
A toy blockchain for the micro:bit radio and MakeCode
- Host: GitHub
- URL: https://github.com/microsoft/pxt-radio-blockchain
- Owner: microsoft
- License: mit
- Created: 2018-02-28T16:17:51.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-06-05T17:35:02.000Z (about 3 years ago)
- Last Synced: 2026-05-25T10:38:58.648Z (24 days ago)
- Topics: makecode
- Language: TypeScript
- Homepage: https://makecode.microbit.org/pkg/microsoft/pxt-radio-blockchain
- Size: 25.4 KB
- Stars: 32
- Watchers: 9
- Forks: 16
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# radio-blockchain
A toy blockchain over radio
## ~ hint
This is blockchain implementation is for educational purposes only.
## ~
## Usage
The library starts as soon as the @boardname@ starts.
It uses the radio.
### Add a block #radioblockchainaddblock
The ```addBlock``` adds a block in the blockchain and broadcast its to peers.
```sig
blockchain.addBlock(0)
```
### Read the values #radioblockchainvalues
Use the ``values`` block to get an array of number
of the values stored in the chain, minus the genesis block.
```sig
blockchain.values()
```
### Filtering values by @boardname@ #radioblockvaluesfrom
You can also get the values contributed by a particular
@boardname@ using ``valuesFrom``. The ``id`` block gives your @boardname@ id.
```sig
blockchain.valuesFrom(blockchain.id())
```
## Events #radioblockchainonevent
Events are raised when the chain is updated (when you received a new chain) or broadcasted.
```sig
blockchain.onEvent(BlockChainEvent.Update, () => {})
```
## License
MIT
## Supported targets
* for PXT/microbit
(The metadata above is needed for package search.)
## References
* https://medium.com/@lhartikk/a-blockchain-in-200-lines-of-code-963cc1cc0e54
* https://medium.com/crypto-currently/lets-build-the-tiniest-blockchain-e70965a248b
* https://medium.com/@micheledaliessi/how-does-the-blockchain-work-98c8cd01d2ae