{"id":34148674,"url":"https://github.com/mrdecryptdecipher/pow-based-blockchain","last_synced_at":"2026-03-12T19:33:46.158Z","repository":{"id":143691497,"uuid":"574706450","full_name":"MrDecryptDecipher/POW-BASED-BLOCKCHAIN","owner":"MrDecryptDecipher","description":"A SIMPLE PROOF OF WORK BASED BLOCKCHAIN WHICH USES HASHING FEATURE TO HASH INPUT, IT ALSO HAS A GENESIS BLOCK AND OTHER NECESSARY FILES TO CREATE POW ALGORITHM","archived":false,"fork":false,"pushed_at":"2022-12-05T22:49:28.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-17T19:51:19.637Z","etag":null,"topics":["bitcoin","blockchain","blockchain-technology","consensus-algorithm","cryptography","decentralized","dlt","proof-of-work"],"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/MrDecryptDecipher.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":"2022-12-05T22:40:00.000Z","updated_at":"2025-05-19T07:37:05.000Z","dependencies_parsed_at":"2023-06-13T00:30:25.739Z","dependency_job_id":null,"html_url":"https://github.com/MrDecryptDecipher/POW-BASED-BLOCKCHAIN","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MrDecryptDecipher/POW-BASED-BLOCKCHAIN","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrDecryptDecipher%2FPOW-BASED-BLOCKCHAIN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrDecryptDecipher%2FPOW-BASED-BLOCKCHAIN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrDecryptDecipher%2FPOW-BASED-BLOCKCHAIN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrDecryptDecipher%2FPOW-BASED-BLOCKCHAIN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrDecryptDecipher","download_url":"https://codeload.github.com/MrDecryptDecipher/POW-BASED-BLOCKCHAIN/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrDecryptDecipher%2FPOW-BASED-BLOCKCHAIN/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30439920,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T14:34:45.044Z","status":"ssl_error","status_checked_at":"2026-03-12T14:09:33.793Z","response_time":114,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["bitcoin","blockchain","blockchain-technology","consensus-algorithm","cryptography","decentralized","dlt","proof-of-work"],"created_at":"2025-12-15T04:51:50.870Z","updated_at":"2026-03-12T19:33:46.142Z","avatar_url":"https://github.com/MrDecryptDecipher.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"SIMPLE PROOF OF WORK BASED BLOCKCHAIN WHICH ALSO PRINTS DATA.\n\u003cbr\u003e\n\n\n\n\u003eThe core of the proof-of-work mechanism is to constantly hash the block itself, and compare the hash value with a series of large numbers calculated according to the difficulty value. If the self-hash is smaller than the large number, it means that the mining is successful, otherwise change its own random number and recalculate. And the program will dynamically adjust the difficulty value according to the block interval time (such as Bitcoin)\n\n\u003cbr\u003e\n\nblock structure\n```go\ntype block struct {\n\t//Hash of the previous block\n\tLasthash string\n\t//Hash of this block\n\tHash string\n\t//The data stored in the block (for example, the Bitcoin UTXO model can be used to store transactions here)\n\tData string\n\t//time stamp\n\tTimestamp string\n\t\n    // block height\n\tHeight int\n\t//difficulty value\n\tDiffNum uint\n\t//random number\n\tNonce int64\n}\n```\nMining function:\nUse the math/big package to calculate a series of large numbers newBigint for actual comparison according to the difficulty value diffNum of the global variable, and at the same time convert the block hash into a large number hashInt and compare the two large numbers numerically. If hashInt is smaller than newBigint then Represents successful mining\n\n```go\n//Block mining (calculate hash by incrementing the nonce value by itself)\nfunc mine(data string) block {\n\tif len(blockchain) \u003c 1 {\n\t\tlog.Panic(\"The genesis block has not been generated yet！\")\n\t}\n\tlastBlock := blockchain[len(blockchain)-1]\n\t// create a new block\n\tnewBlock := new(block)\n\tnewBlock.Lasthash = lastBlock.Hash\n\tnewBlock.Timestamp = time.Now().String()\n\tnewBlock.Height = lastBlock.Height + 1\n\tnewBlock.DiffNum = diffNum\n\tnewBlock.Data = data\n\tvar nonce int64 = 0\n\t//A large number calculated according to the mining difficulty value\n\tnewBigint := big.NewInt(1)\n\tnewBigint.Lsh(newBigint, 256-diffNum) //Equivalent to left shift 1\u003c\u003c256-diffNum\n\tfor {\n\t\tnewBlock.Nonce = nonce\n\t\tnewBlock.getHash()\n\t\thashInt := big.Int{}\n\t\thashBytes, _ := hex.DecodeString(newBlock.Hash)\n\t\thashInt.SetBytes(hashBytes) //Convert the hash value of this block into a string of numbers\n\t\t//If the hash is less than a large number calculated by the mining difficulty value, it means that the mining is successful\n\t\tif hashInt.Cmp(newBigint) == -1 {\n\t\t\tbreak\n\t\t} else {\n\t\t\tnonce++ // If the condition is not met, the random number will be incremented continuously until the hash value of this block is less than the specified large number\n\t\t}\n\t}\n\treturn *newBlock\n}\n```\n\n```go\nfunc main() {\n\t// Create a genesis block\n\tgenesisBlock := new(block)\n\tgenesisBlock.Timestamp = time.Now().String()\n\tgenesisBlock.Data = \"I am the genesis block！\"\n\tgenesisBlock.Lasthash = \"0000000000000000000000000000000000000000000000000000000000000000\"\n\tgenesisBlock.Height = 1\n\tgenesisBlock.Nonce = 0\n\tgenesisBlock.DiffNum = 0\n\tgenesisBlock.getHash()\n\tfmt.Println(*genesisBlock)\n\t//Add the genesis block to the blockchain\n\tblockchain = append(blockchain, *genesisBlock)\n\tfor i := 0; i \u003c 10; i++ {\n\t\tnewBlock := mine(\"nice weather\"+strconv.Itoa(i))\n\t\tblockchain = append(blockchain, newBlock)\n\t\tfmt.Println(newBlock)\n\t}\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrdecryptdecipher%2Fpow-based-blockchain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrdecryptdecipher%2Fpow-based-blockchain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrdecryptdecipher%2Fpow-based-blockchain/lists"}