BMAPjs is a BOB parser for B | MAP
OP_RETURN protocols. It processes transaction outputs and transforms them into self descriptive js objects based on the OP_RETURN protocols it discovers in the data.
It supports B, MAP, AIP, METANET and a list of other popular protocols It ingests structured JSON objects in both BOB and MOM formats.
- A BOB formatted transaction. This is the format used by popular planaria APIs
- npm
npm install bmapjs
using node:
let bmap = require('bmapjs')
or in the browser:
<script src="bmap.js"></script>
let prom = import('./bmap.js')
prom.then((bmap) => {
.. use it here ...
})
Turn a BOB or MOM formatted transaction into a BMAP tx. It will throw an error if the transaction is malformed.
try {
bmap.TransformTx(bob_or_mom_tx)
} catch (e) {
console.error(e)
}
After transforming a transaction it will have a key for each protocol used in the transaction:
{
"AIP": { ... },
"B": { ... },
"MAP": { ... },
"1MAEepzgWei6zKmbsdQSy8wAYL5ySDizKo": { ... }
}
If you want to use a raw transaction, first transform it using BPU, then use bmapjs on the output.
There is a collection of sample transactions listed in the examples.html page.
- BOB
- BMAP (a public BMAPjs pre-formatted planaria indexing MAP, BITPIC, BITKEY, transactions)
- MOM (enables additional fields for MetaNet)
example:
{
"B": {
"content": "{\"name\":\"myname\",\"bio\":\"<p>bio</p>\\n\",\"logo\":\"\"}",
"content-type": "application/json",
"encoding": "utf-8",
"filename": "matter.profile.json"
}
}
example:
{
"MAP": {
"cmd": "SET",
"app": "metalens",
"type": "comment",
"url": "https://twitter.com/",
"user": "Satchmo"
}
}
Response will include metanet relavent keys from MOM Planaria when available. When not available (BOB data source), bmap will provide the "parent" and "node" keys only. These will be provided in the same data structure as MOM Planaria.
{
"METANET": {
"node": {
"a": "15ZCvDUJ6wG1hoiSyw1ftfiRhpKTVGLMnn",
"tx": "70bcbe4dc1ff796389e3de4f5f151cff7eb4a172142468a79677c703afd930b9",
"id": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
},
"parent": {
"a": "15ZCvDUJ6wG1hoiSyw1ftfiRhpKTVGLMnn",
"tx": "577cc5de372f65e33045745129699139568eb46b2ef09d2ca5bf44a9bcb07c71",
"id": "59f2e83ac0607d44d764b9040aaa8dd8741e6169444739464f97422055ad001c"
}
}
}
{
"METANET": {
"node": {
"a": "15ZCvDUJ6wG1hoiSyw1ftfiRhpKTVGLMnn",
"tx": "70bcbe4dc1ff796389e3de4f5f151cff7eb4a172142468a79677c703afd930b9",
"id": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
},
"parent": {
"a": "15ZCvDUJ6wG1hoiSyw1ftfiRhpKTVGLMnn",
"tx": "577cc5de372f65e33045745129699139568eb46b2ef09d2ca5bf44a9bcb07c71",
"id": "59f2e83ac0607d44d764b9040aaa8dd8741e6169444739464f97422055ad001c"
},
"ancestor": [
{
"tx": "06ea0de45680b790d25372bc12b52c7e740e3b10f36d8aabd8b8a31e858a79c2",
"id": "9d9fee655e15decf639cf13617cadaf285ff15c5e5c593e1ff24c38c3c6edbcc",
"a": "1NXHduuvxtXVgsTyXjm9VrbV7Zy8BZ1JHr"
},
{
"tx": "59f2e83ac0607d44d764b9040aaa8dd8741e6169444739464f97422055ad001c",
"id": "44807057a5235e022477d7c75425132d31b0a53f86b9a98cd21dd681c42945f5",
"a": "1j161kyQh6jxWxFySch9Kk6YRt6ZK31jA"
}
],
"child": [],
"head": true
}
}
bitkey_signature
and user_signature
are in base64 encoded binary format
{
"BITKEY": {
"bitkey_signature": "SDQwdkEyVnN0emtIY2VnYXJVTm1WUm1wQ3ZLUVBSdXR4KzczdG9Jcm4vMWxRWU9aQ1lRQ0cyaFhBdHRQRFl0L0h2KzE0dWtUZ25MWVh1UUNsTFp6blBnPQ==",
"user_signature": "SUxzZWpEWXVwMlBEYjltdnJET1dSaWxMSy9Xd1BtVlRiazFOWnZnUHZiczRWVzYyenM1MFY5c3E0akdrQm8yeDlLOG9jSE5acTlLd1hRMkREV0V2OGNjPQ==",
"paymail": "oktets@moneybutton.com",
"pubkey": "0210fdec2372cb65dd9d6adb982101d9cdbb407d9f2e2d5be31cd9d59a561ccacf"
}
}
BITCOM commands
useradd, echo, su, route
{
"BITCOM": [
"$",
"echo",
"delphe_test2",
"to",
"name"
]
}
pubkey
and sig
fields are returned in base64 encoded binary format
{
"BITPIC": {
"paymail": "stockrt@moneybutton.com",
"pubkey": "AoAgqoMucQcdi7kyLHhN4y1HVCPMyVpcPrj75AAoFo/6",
"sig": "SVBJVzU3NnplSnUzODlKNTVPT0RSNjVvSlhDdldYTDY0SWtEa1dOQzNkZ0xBdGZGVUx0MlYzWW1OWkNUQTBsUlV1M2dJMlIrRkswT1JlUnl1Vm9SQjVZPQ=="
}
}
When an unknown protocol is encountered, bmap will keep the incoming format and use the protocol prefix as the key name on the response object:
{
"1MAEepzgWei6zKmbsdQSy8wAYL5ySDizKo": [
{
"b": "MU1BRWVwemdXZWk2ekttYnNkUVN5OHdBWUw1eVNEaXpLbw==",
"s": "1MAEepzgWei6zKmbsdQSy8wAYL5ySDizKo",
"ii": 7,
"i": 0
},
{
"b": "bWF0dGVyLWNyZWF0ZS1wb3N0",
"s": "matter-create-post",
"ii": 8,
"i": 1
},
{
"b": "djE=",
"s": "v1",
"ii": 9,
"i": 2
},
{
"b": "aGVsbG8td29ybGQtcG9zdA==",
"s": "hello-world-post",
"ii": 10,
"i": 3
}
]
}
- AIP
- AIP validation
- B
- BCAT
- Bitcom
- Bitkey
- Bitpic
- D
- HAIP
- HAIP validation
- MAP v1
- MAP v2
- MetaNet
- RON
- SymRe
Beginning with v0.2.0, bmapjs uses BOB as the source format for transaction processing. The previous versions of bmap used TXO formatted transactions. To use bmapjs with TXO data, use v0.1.5.
You can also use BPU to get a BOB format tx from a raw tx, and then parse it with bmapjs v0.2.0 or higher:
const BPU = require('bpu')
const bmapjs = require('bmapjs')
// 'rawtx' is a raw transaction string
(async function() {
let bob = await BPU.parse({
tx: { r: rawtx }
})
let bmap = bmapjs.TransformTx(bob)
...
})()