{"id":13482649,"url":"https://github.com/binded/blockcast","last_synced_at":"2025-12-15T13:11:24.294Z","repository":{"id":34407588,"uuid":"38336692","full_name":"binded/blockcast","owner":"binded","description":"A multi-transaction protocol for storing data in the Bitcoin blockchain.","archived":false,"fork":true,"pushed_at":"2015-10-26T22:37:48.000Z","size":284,"stargazers_count":55,"open_issues_count":0,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-22T18:14:51.438Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.blockai.com","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"williamcotton/blockcast","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/binded.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-30T22:38:26.000Z","updated_at":"2021-03-06T23:18:16.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/binded/blockcast","commit_stats":null,"previous_names":["blockai/blockcast"],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binded%2Fblockcast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binded%2Fblockcast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binded%2Fblockcast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binded%2Fblockcast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binded","download_url":"https://codeload.github.com/binded/blockcast/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245854579,"owners_count":20683379,"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-07-31T17:01:04.103Z","updated_at":"2025-12-15T13:11:19.018Z","avatar_url":"https://github.com/binded.png","language":"JavaScript","funding_links":[],"categories":["Modules"],"sub_categories":[],"readme":"blockcast\n===\n\n[![Build Status](http://drone.d.blockai.com/api/badge/github.com/blockai/blockcast/status.svg?branch=master)](http://drone.d.blockai.com/github.com/blockai/blockcast)\n\nA multi-transaction protocol for storing data in the Bitcoin blockchain.\n\nThis protocol is intended for use while **developing** ```OP_RETURN``` based protocols. Mature protocols should switch to a custom ```OP_RETURN``` method that uses as few transactions as possible to store data. \n\nIn the meantime, save yourself from premature optimizations. Wait until you've figured out your protocol's most basic requirements so you don't hold up developing applications that consume your APIs.\n\nPosting data\n---\n\nIn our examples we're going to use ```bitcoinjs-lib``` to create our wallet.\n\n```javascript\nvar bitcoin = require(\"bitcoinjs-lib\");\n\nvar seed = bitcoin.crypto.sha256(\"test\");\nvar wallet = new bitcoin.Wallet(seed, bitcoin.networks.testnet);\nvar address = wallet.generateAddress();\n\nvar signRawTransaction = function(txHex, cb) {\n  var tx = bitcoin.Transaction.fromHex(txHex);\n  var signedTx = wallet.signWith(tx, [address]);\n  var txid = signedTx.getId();\n  var signedTxHex = signedTx.toHex();\n  cb(false, signedTxHex, txid);\n};\n\nvar commonWallet = {\n  signRawTransaction: signRawTransaction,\n  address: address\n}\n```\n\nWe'll need to provide an instance of a commonBlockchain which will provide functions for getting unspent outputs, propagating a trasnaction, and looking up a transaction by ```txid```.\n\nIn this example we're using the in memory version that is provided by ```mem-common-blockchain```.\n\n\n```javascript\nvar memCommonBlockchain = require(\"mem-common-blockchain\")({\n  type: \"local\"\n});\n\n// or local Bitcoin-Qt.app via the JSON-RPC\n\nvar RpcClient = require('bitcoind-rpc')\n\nvar config = {\n  protocol: 'http',\n  user: 'rpcuser',\n  pass: 'rpcpassword',\n  host: '127.0.0.1',\n  port: '18332'\n}\n\nvar rpc = new RpcClient(config)\n\nvar rpcCommonBlockchain = require('rpc-common-blockchain')({\n  rpc: rpc\n})\n\n// or testnet via blockcypher\n\ntestnetCommonBlockchain = require('blockcypher-unofficial')({\n  network: \"testnet\"\n});\n```\n\nAnd finally we're ready to post.\n\n```javascript\nblockcast.post({\n  data: \"Hello, world! I'm posting a message that is compressed and spread out across a number of bitcoin transactions!\",\n  commonWallet: commonWallet,\n  commonBlockchain: memCommonBlockchain\n}, function(error, response) {\n  console.log(response);\n});\n```\n\nScan for data from a single transaction\n---\n\nWe can also provide the transaction hash from the first transaction's payload.\n\n```javascript\nblockcast.scanSingle({\n  txid: 'fe44cae45f69dd1d6115815356a73b9c5179feff1b276d99ac0e283156e1cd01',\n  commonBlockchain: testnetCommonBlockchain\n}, function(err, body) {\n  var document = JSON.parse(body);\n  console.log(document);\n});\n```\n\nScan for data from a range of blocks\n---\n\nYou can use the [```blockcast-state-engine```](https://github.com/blockai/blockcast-state-engine) module to scan the Bitcoin blockchain for an ordered list of Blockcast data.\n\nHow does it work?\n---\n\nDocuments are compressed using DEFLATE and then embedded across up to 16 Bitcoin transactions in OP_RETURN outputs allowing for total compressed size of no larger than 1277 bytes. \n\nEach blockcast post has a primary transaction identified by the magic header ```0x1f00```. The compressed data can be rebuilt by following the chain of previous transactions back through their inputs and appending data stored in OP_RETURN.\n\n```OP_RETURN 0x1f00032d8d5b4bc4301085ff4ac973d14c9a34c9beb982c20aa28222bee5ea06bb6d4cb3ec45fcef4ed59799e19cf39df92253262b52484b6c4d5b3cbb4e704a1def406a6bc1784a95604a071e7aea```\n\nThe total number of tranactions is stored as the first byte immediately following the magic header. In the above example, ```0x1f0003```, the total transaction count is 3, meaning that two more transactions bust be sequentially scanned in order to reconstruct the full compressed data.\n\nThis is enough space to contain a number of document digest formats, URIs and URNs. This allows for cross-platform content addressable formats between systems like BitTorrent and IPFS. Used by [openpublish](https://github.com/blockai/openpublish/).\n\nWhy Bitcoin?\n---\n\nThe Bitcoin blockchain is the world's first public equal-access data store. Data embedded in the Bitcoin blockchain becomes provably published records signed by recognizable authors.\n\nOther public data stores are unreliable. Bittorrent, Freenet and public-access DHTs cannot guarantee that data will be retrievable.\n\nWhat about polluting the blockchain?\n---\n\nWe will move this protocol to a Bitcoin sidechain designed specifically for public data as soon as the technology for building sidechains becomes available.\n\nIn the meantime we've been using this protocol while prototyping other protocols that rely on storing metadata in the Bitcoin blockchain.\n\nWoodsy Owl says \"Give a Hoot! Don't Pollute!\"\n\nWhat about an alternative currency like Namecoin?\n---\n\nNamecoin doesn't match all specific use-cases as documents expire after ~200 days. \n\nIt also lacks the infrastructure of exchanges, APIs, tools, and software that support Bitcoin.\n\nUltimately we feel that Bitcoin sidechains are a better approach to crypto-currencies than having competing alt-coins.\n\nBuilding any application on top of Bitcoin creates an incentive to own Bitcoin. Incentives to own Bitcoin keep miners happy. Happy miners create happy Bitcoin.\n\nWas this always intended for prototyping?\n---\n\nNo, this started out as some sort of \"Twitter on the Blockchain\" protocol but it quickly became clear that the current Bitcoin blockchain is most useful for storing metadata related to digital assets and not as a generic decentralized data store.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinded%2Fblockcast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinded%2Fblockcast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinded%2Fblockcast/lists"}