{"id":21607449,"url":"https://github.com/janrockdev/microblockchain","last_synced_at":"2025-03-18T15:21:17.382Z","repository":{"id":144360324,"uuid":"379880273","full_name":"janrockdev/microblockchain","owner":"janrockdev","description":"µBlockchain is a Golang based minimalistic blockchain project to demonstrate all functionalities of blockchain/crypto-assets use case.","archived":false,"fork":false,"pushed_at":"2022-01-26T20:45:32.000Z","size":27,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-24T19:34:47.274Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/janrockdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-24T10:01:10.000Z","updated_at":"2022-01-26T20:56:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"a76bfdcd-4765-4261-bddc-2c2615837b36","html_url":"https://github.com/janrockdev/microblockchain","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janrockdev%2Fmicroblockchain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janrockdev%2Fmicroblockchain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janrockdev%2Fmicroblockchain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janrockdev%2Fmicroblockchain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/janrockdev","download_url":"https://codeload.github.com/janrockdev/microblockchain/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244246552,"owners_count":20422459,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T20:30:55.185Z","updated_at":"2025-03-18T15:21:17.359Z","avatar_url":"https://github.com/janrockdev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# µBlockchain Project\n\n**Introduction**:\u003cbr/\u003e\nµBlockchain is a Golang based minimalistic blockchain project to demonstrate all functionalities of blockchain/crypto-assets use case.\n\n**Usage**:\u003cbr/\u003e\n```\n----------------------------------------------------------------------------------------\nMicroblockchain usage: \n----------------------------------------------------------------------------------------\ngetbalance -address ADDRESS - get balance for ADDRESS\ncreateblockchain -address ADDRESS - creates a blockchain and rewards the mining fee for ADDRESS\nmineblock -address ADDRESS - creates a block and rewards the mining fee for ADDRESS\nprintchain - prints the blocks in the chain\nsend -from FROM -to TO -amount AMOUNT - send AMOUNT of coins from one ADDRESS to another ADDRESS\ncreatewallet - creates a new wallet\nlistaddresses - lists the addresses in the wallet file\n----------------------------------------------------------------------------------------\nExample: go run main.go -colors true --help (or go build and then ./microblockchain --help)\n----------------------------------------------------------------------------------------\n```\n**Example**:\u003cbr/\u003e\n```shell\ngo build\n```\nCreate genesis block and first wallet (reward: 100):\u003cbr/\u003e\n```shell\ncreateblockchain -address 1JMQeu1tyCnErcWXjWuh4NfU95pVSqtZLC\n# output\n# badger 2021/06/24 08:43:40 INFO: All 0 tables opened in 0s\n# 00002488975f5c22e3ad33ec5f8a3dc91e390f3fa92b68726b26ff31666d9729\n# Genesis block created!\n# badger 2021/06/24 08:43:41 DEBUG: Storing value log head: {Fid:0 Len:42 Offset:569}\n# badger 2021/06/24 08:43:41 INFO: Got compaction priority: {level:0 score:1.73 dropPrefixes:[]}\n# badger 2021/06/24 08:43:41 INFO: Running for level: 0\n# badger 2021/06/24 08:43:41 DEBUG: LOG Compact. Added 3 keys. Skipped 0 keys. Iteration took: 145.28µs\n# badger 2021/06/24 08:43:41 DEBUG: Discard stats: map[]\n# badger 2021/06/24 08:43:41 INFO: LOG Compact 0-\u003e1, del 1 tables, add 1 tables, took 46.044145ms\n# badger 2021/06/24 08:43:41 INFO: Compaction for level: 0 DONE\n# badger 2021/06/24 08:43:41 INFO: Force compaction on level 0 done\n# Finished creating chain        \n```\nCreate wallet #2:\u003cbr/\u003e\n```shell\n./microblockchain createwallet\n# output\n# New address is: 1JMQeu1tyCnErcWXjWuh4NfU95pVSqtZLC\n```\nMine a new block with reward 100:\u003cbr/\u003e\n```shell\n./microblockchain mineblock -address 1CVFX4qaBwpti5wRGdJNDxCwxBbzUEWRKG\n# output\n# badger 2021/06/24 08:44:54 INFO: All 1 tables opened in 0s\n# badger 2021/06/24 08:44:54 INFO: Replaying file id: 0 at offset: 611\n# badger 2021/06/24 08:44:54 INFO: Replay took: 27.384µs\n# badger 2021/06/24 08:44:54 DEBUG: Value log discard stats empty\n# 000031a8165a609c802d607459a2c8c267b4ee80c4441fe1c903d070653e86e7\n# Finished adding block for address 1CVFX4qaBwpti5wRGdJNDxCwxBbzUEWRKG\n# badger 2021/06/24 08:44:58 DEBUG: Storing value log head: {Fid:0 Len:42 Offset:1228}\n# badger 2021/06/24 08:44:58 INFO: Got compaction priority: {level:0 score:1.73 dropPrefixes:[]}\n# badger 2021/06/24 08:44:58 INFO: Running for level: 0\n# badger 2021/06/24 08:44:58 DEBUG: LOG Compact. Added 6 keys. Skipped 0 keys. Iteration took: 372.882µs\n# badger 2021/06/24 08:44:58 DEBUG: Discard stats: map[]\n# badger 2021/06/24 08:44:58 INFO: LOG Compact 0-\u003e1, del 2 tables, add 1 tables, took 45.573949ms\n# badger 2021/06/24 08:44:58 INFO: Compaction for level: 0 DONE\n# badger 2021/06/24 08:44:58 INFO: Force compaction on level 0 done\n```\nCheck balance of wallet #1:\u003cbr/\u003e\n```shell\n./microblockchain getbalance -address 1JMQeu1tyCnErcWXjWuh4NfU95pVSqtZLC\n# output\n# badger 2021/06/24 10:04:23 INFO: All 1 tables opened in 0s\n# badger 2021/06/24 10:04:23 INFO: Replaying file id: 0 at offset: 1270\n# badger 2021/06/24 10:04:23 INFO: Replay took: 16.131µs\n# badger 2021/06/24 10:04:23 DEBUG: Value log discard stats empty\n# Balance of 1JMQeu1tyCnErcWXjWuh4NfU95pVSqtZLC: 100\n# badger 2021/06/24 10:04:23 INFO: Got compaction priority: {level:0 score:1.73 dropPrefixes:[]}\n```\nCheck balance of wallet #2:\u003cbr/\u003e\n```shell\n./microblockchain getbalance -address 1CVFX4qaBwpti5wRGdJNDxCwxBbzUEWRKG\n# output\n# badger 2021/06/24 10:04:39 INFO: All 1 tables opened in 1ms\n# badger 2021/06/24 10:04:39 INFO: Replaying file id: 0 at offset: 1270\n# badger 2021/06/24 10:04:39 INFO: Replay took: 6.944µs\n# badger 2021/06/24 10:04:39 DEBUG: Value log discard stats empty\n# Balance of 1CVFX4qaBwpti5wRGdJNDxCwxBbzUEWRKG: 100\n# badger 2021/06/24 10:04:39 INFO: Got compaction priority: {level:0 score:1.73 dropPrefixes:[]}\n```\nSend crypto from wallet #1 to wallet #2:\u003cbr/\u003e\n```shell\n./microblockchain send -from 1JMQeu1tyCnErcWXjWuh4NfU95pVSqtZLC -to 1CVFX4qaBwpti5wRGdJNDxCwxBbzUEWRKG -amount 20 \n# output   \n# badger 2021/06/24 10:09:53 INFO: All 1 tables opened in 0s\n# badger 2021/06/24 10:09:53 INFO: Replaying file id: 0 at offset: 1270\n# badger 2021/06/24 10:09:53 INFO: Replay took: 22.517µs\n# badger 2021/06/24 10:09:53 DEBUG: Value log discard stats empty\n# 00001063b36a0dce4125017a468800d076897ac396606b38fafe205cf658466a\n# Success!\n# badger 2021/06/24 10:09:55 DEBUG: Storing value log head: {Fid:0 Len:42 Offset:1962}\n# badger 2021/06/24 10:09:55 INFO: Got compaction priority: {level:0 score:1.73 dropPrefixes:[]}\n# badger 2021/06/24 10:09:55 INFO: Running for level: 0\n# badger 2021/06/24 10:09:55 DEBUG: LOG Compact. Added 7 keys. Skipped 2 keys. Iteration took: 61.681µs\n# badger 2021/06/24 10:09:55 DEBUG: Discard stats: map[0:64]\n# badger 2021/06/24 10:09:55 INFO: LOG Compact 0-\u003e1, del 2 tables, add 1 tables, took 44.76387ms\n# badger 2021/06/24 10:09:55 INFO: Compaction for level: 0 DONE\n# badger 2021/06/24 10:09:55 INFO: Force compaction on level 0 done\n```\nCheck balance of wallet #1:\u003cbr/\u003e\n```shell\n./microblockchain getbalance -address 1JMQeu1tyCnErcWXjWuh4NfU95pVSqtZLC\n# output      \n# badger 2021/06/24 10:10:12 INFO: All 1 tables opened in 0s\n# badger 2021/06/24 10:10:12 INFO: Replaying file id: 0 at offset: 2004\n# badger 2021/06/24 10:10:12 INFO: Replay took: 7.396µs\n# badger 2021/06/24 10:10:12 DEBUG: Value log discard stats empty\n# Balance of 1JMQeu1tyCnErcWXjWuh4NfU95pVSqtZLC: 80\n#  badger 2021/06/24 10:10:12 INFO: Got compaction priority: {level:0 score:1.73 dropPrefixes:[]}\n```\nCheck balance of wallet #1:\u003cbr/\u003e\n```shell\n./microblockchain getbalance -address 1CVFX4qaBwpti5wRGdJNDxCwxBbzUEWRKG                                         \n# output\n# badger 2021/06/24 10:10:17 INFO: All 1 tables opened in 0s\n# badger 2021/06/24 10:10:17 INFO: Replaying file id: 0 at offset: 2004\n# badger 2021/06/24 10:10:17 INFO: Replay took: 12.511µs\n# badger 2021/06/24 10:10:17 DEBUG: Value log discard stats empty\n# Balance of 1CVFX4qaBwpti5wRGdJNDxCwxBbzUEWRKG: 120\n# badger 2021/06/24 10:10:17 INFO: Got compaction priority: {level:0 score:1.73 dropPrefixes:[]}\n```\nPrint all blocks:\u003cbr/\u003e\n```shell\n./microblockchain printchain\n# output                                            \n# badger 2021/06/24 10:10:34 INFO: All 1 tables opened in 0s\n# badger 2021/06/24 10:10:34 INFO: Replaying file id: 0 at offset: 2004\n# badger 2021/06/24 10:10:34 INFO: Replay took: 7.017µs\n# badger 2021/06/24 10:10:34 DEBUG: Value log discard stats empty\n# Previous hash: 000031a8165a609c802d607459a2c8c267b4ee80c4441fe1c903d070653e86e7\n# Hash: 00001063b36a0dce4125017a468800d076897ac396606b38fafe205cf658466a\n# Pow: true\n# \n# Previous hash: 00002488975f5c22e3ad33ec5f8a3dc91e390f3fa92b68726b26ff31666d9729\n# Hash: 000031a8165a609c802d607459a2c8c267b4ee80c4441fe1c903d070653e86e7\n# Pow: true\n# \n# Previous hash: \n# Hash: 00002488975f5c22e3ad33ec5f8a3dc91e390f3fa92b68726b26ff31666d9729\n# Pow: true\n# \n# badger 2021/06/24 10:10:34 INFO: Got compaction priority: {level:0 score:1.73 dropPrefixes:[]}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanrockdev%2Fmicroblockchain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjanrockdev%2Fmicroblockchain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanrockdev%2Fmicroblockchain/lists"}