btc

所属分类:IPFS
开发工具:JavaScript
文件大小:0KB
下载次数:0
上传日期:2022-08-10 17:50:56
上 传 者sh-1993
说明:  Truth machine-一个用于比特币和以太坊区块链文本写入和读取以及使用去中心化......进行验证和托管的系统...,
(Truth machine - A system for bitcoin and ethereum blockchain text writing and reading, as well as verification and escrow using decentralized blockchain and IPFS technologies.)

文件列表:
LICENSE (35149, 2022-08-10)
about (3471, 2022-08-10)
examples/ (0, 2022-08-10)
examples/read.js (482, 2022-08-10)
examples/write.js (718, 2022-08-10)
lib/ (0, 2022-08-10)
lib/constants.js (300, 2022-08-10)
lib/utils.js (17011, 2022-08-10)
package-lock.json (8918, 2022-08-10)
package.json (887, 2022-08-10)

# btc-truth-machine as a reference we took this library, fixed it, and are starting to rewrite and improve it: https://github.com/3s3s/blockchaindata-lib WRITING A TEXT DOCUMENT IN BITCOIN BLOCKCHAIN The article on which this paper is based: Install a library that communicates with bitcoin-cli https://www.npmjs.com/package/blockchaindata-lib Write code in Node.js to write text into a blockchain that will read data from a text file ```JavaScript 'use strict'; const blockchaindata = require('btc-truth-machine'); const bitcoin = require('bitcoinjs-lib'); const fs = require('fs'); blockchaindata.updateNetwork('http://127.0.0.1:18332/wallet/NAME','rpc_btc_test', 'rpc_btc_password_test', bitcoin.networks.testnet); async function write() { try { const data = fs.readFileSync('text.txt', 'utf8'); const ret1 = await blockchaindata.SaveTextToBlockchain(data); if (ret1.result == false) throw new Error("SaveTextToBlockchain failed, message: "+ret1.message); console.log("SaveTextToBlockchain success! txid="+ret1.txid+"\n--------------------------") } catch (e) { console.log(e.message) } } write() ``` Maximum file size ~65 Kilobytes (in testnet). Currently working on expanding mainnet max capacity which is about 40 symbols now. After a successful write operation hash will be returned to the transaction, which contains our document, compressed using the deflate algorithm by the zlib library After that you can read the file and display its content in the console or redirect the output to another file ```JavaScript 'use strict'; const blockchaindata = require('btc-truth-machine'); const hash = '557405e2e5e1919f1b3566493a478bf45400607f54a0b371a321242faaa6e437'; async function read() { try { const savedObject = await blockchaindata.GetObjectFromBlockchain(hash); if (savedObject.type == 'error') throw new Error(savedObject.message) console.log(Buffer.from(savedObject.base64, 'base64').toString('utf8')); } catch(e) { console.log(e.message) } } read(); ```

近期下载者

相关文件


收藏者