boostpow-js
BoostPow Javascript SDK - matterpool.io
Boost POW Javascript Library
Boost Proof of Work Protocol https://boostpow.com
Boost is a new type of content ranking system that enables users to increase the amount of energy required to mine or process their content. Users will boost their post as a way to signal to the network that they believe their information is valuable. Boosted posts will appear in the boost feed – ordered by the amount of energy requested for their information.
Preview
A Boost Pow String (also called "Boost Header") consist of an 80 byte string that is encoded identically to a Bitcoin Block Header. The string is valid if the hash256 of the string is less than the target difficulty specified inside the string.
We can objectively order content of Boost Pow Strings from most to least energy (difficulty) in a way that is self-evident and provable. The world's first provably fair content ranking system powered by native Bitcoin Proof of Work.
Boost Pow String:
010000009500c43a25c624520b5100adf82cb9f9da72fd2447a496bc600b0000000000006cd862370395dedf1da2841ccda0fc489e3039de5f1ccddef0e834991a65600ea6c8cb4db3936a1ae3143991
And it's hash256 is: 0000000000002917ed80650c6174aac8dfc46f5fe36480aaef682ff6cd83c3ca
Sample code to verify Boost Pow String:
// Validate a Boost Pow String// Underneath bsv.js validates the string *exactly* like a Bitcoin Block Headerconst powString = boostBoostPowString;// Print out the decoded stringconsole;/*{ hash: '0000000086915e291fe43f10bdd8232f65e6eb64628bbb4d128be3836c21b6cc', content: '00000000000000000000000000000000000000000048656c6c6f20776f726c64', bits: 486604799, difficulty: 1, metadataHash: "acd8278e84b037c47565df65a981d72fb09be5262e8783d4cf4e42633615962a", time: 1305200806, nonce: 3698479534, category: 1,}*/
Installation
npm install boostpow-js --save
Boost POW
A Protocol for Buying and Selling Proof-of-Work Embedded in Bitcoin Script
Boost is a new type of content ranking system that enables users to increase the amount of energy required to mine or process their content. Users will boost their post as a way to signal to the network that they believe their information is valuable. Boosted posts will appear in the boost feed – ordered by the amount of energy requested for their information.
Links:
MoneyButton, Relay, TwetchPay Integration
Easily integrate MoneyButton, Relay, and TwetchPay
Consult the respective documentation for additional details. All services support the 'outputs' format presented below for easy integration.
const boost = ;// Create a Boost request with your dataconst boostJob = boostBoostPowJob;// Construct a MoneyButton or Relay Outputconst boostOutputs = script: boostJob amount: boostJob * 00001 // Charge a fee for the Boost. In future this will be a feeQuote system. Higher payout the more likely a miner will mine the boost relativity to the diff. currency: "BSV"; // Now you can populate MoneyButton, Relay or TwetchPay with the outputs:twetchPay;
The above command returns JSON structured like this after successfully submitting.
Create Boost Job
Create Boost Job Request.
See unit tests for more examples
curl -X POST https://graph.boostpow.com/api/v1/main/boost/jobs -H 'Content-Type: application/json' \-d '{ "rawtx": "...raw tx hex containing boost output..."}'
const boost = ;const result = await boost;
The above command returns JSON structured like this:
This endpoint retrieves found Boosts matching the search querie
HTTP Request
POST https://graph.boostpow.com/api/v1/main/boost/jobs
URL Parameters
Parameter | Description |
---|---|
rawtx | Raw boost tx |
Get Boost Job Status
Get Boost Job Status. Returns the status of a Boost Job. If it's mined you will see the 'boostPowString' and other fields populated.
See unit tests for more examples
curl https://graph.boostpow.com/api/v1/main/boost/jobs/cdd2822902bcc90bd6e4651475e2476034700353e7a0335a42783c1a1050d267
const boost = ;const result = await boost;
The above command returns JSON structured like this:
This endpoint retrieves found Boosts matching the search query
HTTP Request
POST https://graph.boostpow.com/api/v1/main/boost/jobs
URL Parameters
Parameter | Description |
---|---|
txid | Txid of the boost job to get the status |
Search Content
Search by specific fields in utf8 or raw hex (make sure to use the file byte padding length).
See unit tests for more examples
NOTE: You must validate the boostPowString and boostPowMetadata to confirm POW is correct. Use BoostSignalRanker, BoostSignalSummary, or BoostPowString to do this efficiently to produce a list sorted by difficulty (energy)
Examples
See GraphSearchQuery interface below for all the options
Find all Boost for content=hello
Find all Boost for content=hello in category=mttr
curl "https://graph.boostpow.com/api/v1/main/boost/search?content=hello&contenthex=00000000000000000000000000000000000000000000000000000068656c6c6f&minedTimeFrom=0&minedTimeEnd=&category=&categoryhex=&tag=&taghex=&additionaldata=&additionaldatahex=&debug=true&expanded=true&"
const boost = ; const result = await boost;const ranker = boostBoostSignalRanker;// By default it ranks category by category and content then sorts by total energyconsole;console;console;// See more options for displaying retrieved results /*// You can search by many different fields, including arrays for the content*, tag*, category*, additionaldata* fields.export interface GraphSearchQuery { contentutf8?: string, content?: string, contenthex?: string, tagutf8?: string, tag?: string, taghex?: string, categoryutf8?: string, category?: string, categoryhex?: string, usernoncehex?: string, additionaldatahex?: string, additionaldatautf8?: string, additionaldata?: string, limit?: number createdTimeFrom?: number, createdTimeEnd?: number, minedTimeFrom?: number, minedTimeEnd?: number, boostPowString?: string, boostHash?: string, boostJobId?: string, boostJobProofId?: string, txid?: string, spentTxid?: string, unmined?: any, debug?: boolean, expanded?: boolean; be?: boolean, // big endian or not paginationToken?: string, // token to use to paginate for everything after}*/
The above command returns JSON structured like this:
This endpoint retrieves found Boosts matching the search querie
HTTP Request
GET https://graph.boostpow.com/api/v1/main/boost/search?content=hello&contenthex=00000000000000000000000000000000000000000000000000000068656c6c6f&minedTimeFrom=0&minedTimeEnd=&category=&categoryhex=&tag=&taghex=&additionaldata=&additionaldatahex=&debug=true&expanded=true&
URL Parameters
Parameter | Description |
---|---|
address | The address to retrieve balance for |
contentutf8 | same as 'contetnt' |
content | Search by utf8 content match |
contenthex | Search by hex content match |
tagutf8 | Same as 'tag' |
tag | Search by utf8 tag match |
taghex | Search by tag hex |
categoryutf8 | Same as 'category' |
category | Search by utf8 |
categoryhex | Search by hex |
additionaldatahex | Search by hex |
additionaldatautf8 | Same as 'additionaldata' |
additionaldata | Search by utf8 |
limit | limit resultst to this many. (not used for now) |
createdTimeFrom | Search from when the job was saved in local db |
createdTimeEnd | Search to when the job was saved in local db |
minedTimeFrom | Search only mined from or after |
minedTimeEnd | Search only mined until or before |
boostPowString | Search by exact POW string match |
boostHash | Search by exact Boosthash mach |
boostJobId | Search by txid+vout for the boost job |
boostJobProofId | Search by spenttxid+vout for the boost job proof |
txid | Search by the boost job txid |
spentTxid | Search by the boost job proof txid |
unmined | 'true', 'false', 'only' -- whether to include unmined boost jobs in search results |
debug | boolean - default true |
expanded | boolean - default true |
be | boolean Big endian or not |
paginationToken | token to use to paginate for everything after |
Contact
Contact us for feedback and questions, we love to hear your feedback. @mxtterpool
Browser Include
// Nodevar boost = ;
<!-- Browser -->
Boost Content Ranking
Easily query your own content and cross check against Boost POW signals to obtain the Boost Rank.
It leaves your existing objects the same, but adds a 'hash' and 'boostpow' member variables added to your objects.
Sample:
const boostpow = ; const ranker = await boostpow; // Or use standalone with: // const ranker = boostpow.BoostSignalRanker.fromArray(result); const boostRanked = ranker; // boostRanked responsne sample: /* [ { "hash":"4048289b19a77bd6e7a3acebe90fa975faa1ea1445e59bccfb3ca79b6d0e0e0e", "boostpow":{ "signals":[ { "boosthash":"0000000002ec8c1e72aa09ebb0dc55a0d24055626d41778a7ebd3ef635732eeb", "boostPowString":"420000000e0e0e6d9ba73cfbcc9be54514eaa1fa75a90fe9ebaca3e7d67ba7199b2848402f8e540524bc0dbacc53e7c33eb7906dbf0f3ffad41b141b57c5ee3dee02016ac610065f0842081c0ceb69b2", "boostPowMetadata":"000000000000000000000000000000000000000092e4d5ab4bb067f872d28f44d3e5433e56fca1900c67e2940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "boostPowJobId":"8aba9c2f2d3274bb0fa9c335621cafa4ec198ef68e17469e3f1e9c901dfc3f5a.1", "boostPowJobProofId":"5f9da48a4b7b919d8a7ebfe485593e7c962e574ee970d385e1d92bfd50c0fd83.0", "contenthex":"4048289b19a77bd6e7a3acebe90fa975faa1ea1445e59bccfb3ca79b6d0e0e0e", "category":"\u0000\u0000\u0000B", "categoryhex":"00000042", "userNoncehex":"00000000", "additionalData":"", "additionalDatahex":"000000000000000000000000000000000000000000000000000000000000000000000000", "tag":"", "taghex":"0000000000000000000000000000000000000000", "metadataHash":"6a0102ee3deec5571b141bd4fa3f0fbf6d90b73ec3e753ccba0dbc2405548e2f", "minerPubKeyHash":"92e4d5ab4bb067f872d28f44d3e5433e56fca190", "time":1594233030, "difficulty":31.00001478 }, { "boosthash":"00000000519fadfaae536cf55b14e9f724e3cd3d52444d778258446f27fa0683", "boostPowString":"420000000e0e0e6d9ba73cfbcc9be54514eaa1fa75a90fe9ebaca3e7d67ba7199b28484007bd567870ceb5afb08d6b245dffc0815adc900771f10a627fad51a38857193e5e3b045fffff001d15325cc6", "boostPowMetadata":"000000000000000000000000000000000000000092e4d5ab4bb067f872d28f44d3e5433e56fca1900c64e3b70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "boostPowJobId":"7702356e61bfd118e739a7579dfe6bb142ecea142e753b2ac4bcc9e6b1a4407d.0", "boostPowJobProofId":"2ca5e31857d41182134d0e33163377ddfbbf860881bf4a178762bdbbebab47b4.0", "contenthex":"4048289b19a77bd6e7a3acebe90fa975faa1ea1445e59bccfb3ca79b6d0e0e0e", "category":"\u0000\u0000\u0000B", "categoryhex":"00000042", "userNoncehex":"00000000", "additionalData":"", "additionalDatahex":"000000000000000000000000000000000000000000000000000000000000000000000000", "tag":"", "taghex":"0000000000000000000000000000000000000000", "metadataHash":"3e195788a351ad7f620af1710790dc5a81c0ff5d246b8db0afb5ce707856bd07", "minerPubKeyHash":"92e4d5ab4bb067f872d28f44d3e5433e56fca190", "time":1594112862, "difficulty":1 }, { "boosthash":"0000000072108f845702ed90d55bf74069f25b0899f99eb7b93a64e37e1f83de", "boostPowString":"420000000e0e0e6d9ba73cfbcc9be54514eaa1fa75a90fe9ebaca3e7d67ba7199b2848405ce0d65410ad2cf32eabd8f4dfe0436d746e76b340e98c4442f21dfd3bf86e9b4bb5035fffff001d18cad831", "boostPowMetadata":"000000000000000000000000000000000000000092e4d5ab4bb067f872d28f44d3e5433e56fca1900c64019f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "boostPowJobId":"a7be0275f92cf2d173ece823834b200da34f9bbbcc5c3342390729b17e7ce2da.0", "boostPowJobProofId":"1893bf9774399c281e56689db426678b48775dab6b7909320453a422f63e59cf.0", "contenthex":"4048289b19a77bd6e7a3acebe90fa975faa1ea1445e59bccfb3ca79b6d0e0e0e", "category":"\u0000\u0000\u0000B", "categoryhex":"00000042", "userNoncehex":"00000000", "additionalData":"", "additionalDatahex":"000000000000000000000000000000000000000000000000000000000000000000000000", "tag":"", "taghex":"0000000000000000000000000000000000000000", "metadataHash":"9b6ef83bfd1df242448ce940b3766e746d43e0dff4d8ab2ef32cad1054d6e05c", "minerPubKeyHash":"92e4d5ab4bb067f872d28f44d3e5433e56fca190", "time":1594078539, "difficulty":1 }, { "boosthash":"0000000069f7d3f8d42b2c1fc1b1d03d25e52effebb29e59608352c95c3412ff", "boostPowString":"420000000e0e0e6d9ba73cfbcc9be54514eaa1fa75a90fe9ebaca3e7d67ba7199b2848405ce0d65410ad2cf32eabd8f4dfe0436d746e76b340e98c4442f21dfd3bf86e9ba5b3035fffff001d0576b501", "boostPowMetadata":"000000000000000000000000000000000000000092e4d5ab4bb067f872d28f44d3e5433e56fca1900c64019f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "boostPowJobId":"4fce8854df6519ed9af56c91b771b742605c4c830fd01bd299fc05919060a65d.0", "boostPowJobProofId":"6e97d3f4eee3adf39136699a0bdb0e95838b7ffed8c523927421eccd711c04af.0", "contenthex":"4048289b19a77bd6e7a3acebe90fa975faa1ea1445e59bccfb3ca79b6d0e0e0e", "category":"\u0000\u0000\u0000B", "categoryhex":"00000042", "userNoncehex":"00000000", "additionalData":"", "additionalDatahex":"000000000000000000000000000000000000000000000000000000000000000000000000", "tag":"", "taghex":"0000000000000000000000000000000000000000", "metadataHash":"9b6ef83bfd1df242448ce940b3766e746d43e0dff4d8ab2ef32cad1054d6e05c", "minerPubKeyHash":"92e4d5ab4bb067f872d28f44d3e5433e56fca190", "time":1594078117, "difficulty":1 }, { "boosthash":"000000002888ded933784a8a714618a1de278230e81f3cf3856a55ab18445886", "boostPowString":"420000000e0e0e6d9ba73cfbcc9be54514eaa1fa75a90fe9ebaca3e7d67ba7199b284840eed77e74a924595d06d1565f6f1dbd5fcb7ddf7ac0cb8157c367757369d0fe62c293045fffff001d040a2233", "boostPowMetadata":"000000000000000000000000000000000000000092e4d5ab4bb067f872d28f44d3e5433e56fca1900c6571770000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "boostPowJobId":"fa562caf0455f4903c849ae89a479ac8f5006b68e1a0131625b2554d89c0732c.0", "boostPowJobProofId":"9de83906e6c55c7370f05cf50942fd6fd6634e321f28dfd62da609a8c628b867.0", "contenthex":"4048289b19a77bd6e7a3acebe90fa975faa1ea1445e59bccfb3ca79b6d0e0e0e", "category":"\u0000\u0000\u0000B", "categoryhex":"00000042", "userNoncehex":"00000000", "additionalData":"", "additionalDatahex":"000000000000000000000000000000000000000000000000000000000000000000000000", "tag":"", "taghex":"0000000000000000000000000000000000000000", "metadataHash":"62fed069737567c35781cbc07adf7dcb5fbd1d6f5f56d1065d5924a9747ed7ee", "minerPubKeyHash":"92e4d5ab4bb067f872d28f44d3e5433e56fca190", "time":1594135490, "difficulty":1 } ], "totalDifficulty":35.00001478, "lastSignalTime":1594078117, "recentSignalTime":1594233030 } }, { "hash":"eb497f88173ac22d0542076e6e4d8e58d8afa0591d60925c4679216a47df35e1", "boostpow":{ "signals":[ { "boosthash":"000000004e70c6a0c24ab8ece1b522e3074cffec7a95fed2ead8129f27bdf936", "boostPowString":"42000000e135df476a2179465c92601d59a0afd8588e4d6e6e0742052dc23a17887f49eb0bc5fe947c636ff5872780b4572f625202622d5fdb3a94318b3dd7071f6a9742891a045fffff001d02f6b838", "boostPowMetadata":"67736f240000000000000000000000000000000092e4d5ab4bb067f872d28f44d3e5433e56fca1900c64a6aa0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "boostPowJobId":"a1482fb5ee09f2a3101624038d8a89b9ef8cfd436c2033e36b352698be004c16.1", "boostPowJobProofId":"20673d9d7b56e9fc5f6490d4ece76b84e0665d82921afb70f6b4a48c97ef2b51.0", "contenthex":"eb497f88173ac22d0542076e6e4d8e58d8afa0591d60925c4679216a47df35e1", "category":"\u0000\u0000\u0000B", "categoryhex":"00000042", "userNoncehex":"00000000", "additionalData":"", "additionalDatahex":"000000000000000000000000000000000000000000000000000000000000000000000000", "tag":"$osg", "taghex":"00000000000000000000000000000000246f7367", "metadataHash":"42976a1f07d73d8b31943adb5f2d620252622f57b4802787f56f637c94fec50b", "minerPubKeyHash":"92e4d5ab4bb067f872d28f44d3e5433e56fca190", "time":1594104457, "difficulty":1 } ], "totalDifficulty":1, "lastSignalTime":1594104457, "recentSignalTime":1594104457 } } ]);
Build and Test
npm install
npm run build
npm run test
Any questions or ideas?
@mxtterpool