-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathREADME.B
154 lines (101 loc) · 4.77 KB
/
README.B
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# B://
> Bitcoin Data Protocol
Store and reference data on the Bitcoin blockchain.
![store](b://ce41326c049b216a3ecb3f2609285ced59da9a3cdf6f03c6c0abcc2864d99c06)
![reference](b://dcdee6a626595bcd6ad2134274acf58c13f398dcc16c35f73d54b42e09fb711c)
<br>
# Intro
B is an OP_RETURN protocol to **store** and **reference** arbitrary data on Bitcoin.
The design goal:
1. The simplest protocol to upload arbitrary media to the blockchain
2. A protocol to **reference** previously uploaded media from another **on-chain media**.
<br>
# Protocol
- The prefix for B is [19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut](https://babel.bitdb.network/query/1DHDifPvtPgKFPZMRSxmVHhiPvFmxZwbfh/ewogICJ2IjogMywKICAicSI6IHsKICAgICJmaW5kIjogewogICAgICAib3V0LnMxIjogIjE5SHhpZ1Y0UXlCdjN0SHBRVmNVRVF5cTFwelpWZG9BdXQiCiAgICB9LAogICAgInByb2plY3QiOiB7CiAgICAgICJvdXQubHMyIjogMCwgIm91dC5saDIiOiAwLCAib3V0LmkiOiAwLCAib3V0LmIxIjogMCwgIm91dC5iMyI6IDAsICJvdXQuaDEiOiAwLCAib3V0LmgzIjogMAogICAgfSwKICAgICJsaW1pdCI6IDEwCiAgfSwKICAiciI6IHsKICAgICJmIjogIlsuW10gfCB7IHRyYW5zYWN0aW9uOiAudHguaCwgYmxvY2s6IC5ibGssIHB1c2hkYXRhOiB7IGIwOiBcIk9QX1JFVFVSTlwiLCBzMTogLm91dFswXS5zMSwgbGIyOiAub3V0WzBdLmxiMiwgczM6IC5vdXRbMF0uczMgfSB9XSIKICB9Cn0=), generated using [Bitcom](https://bitcom.bitdb.network)
Here's an example of what **POST transactions** look like:
```
OP_RETURN
19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut
[Data]
[Media Type]
[Encoding]
[Filename]
```
The order is deliberately `data`, `media type`, and `encoding`, `filename`, in the order of significance (With future extensibility through adding additional push data).
1. **Data:** data to store
2. **Media Type:** As listed at https://www.iana.org/assignments/media-types/media-types.xhtml
3. **Encoding:** As listed at https://www.iana.org/assignments/character-sets/character-sets.xhtml (The default is `binary`)
4. **Filename:** a filename to store the blob as (the default has no filename and just stored as a blob, identified simply by the txid)
Example: HTML
```
OP_RETURN 19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut <html><body>hello world</body></html> text/html UTF-8 hello.html
```
<br>
# Note
**B://** is NOT a protocol for handling authenticated and encrypted media (That would be a much more complex problem). The main design goal of B is:
1. **Public:** Public assets
2. **Simple:** Simple to implement
3. **Versatile:** Easily pluggable to any application in any context
4. **Extensible:** Future extensibility with additional push data support
<br>
# Demo
Try it here: https://b.bitdb.network
<br>
# Usage
## 1. Uploading Large Media
Let's upload an image.
You can try it [here](https://b.bitdb.network) (up to 100KB)
When you select a file, it **directly writes the binary (ArrayBuffer)** into Bitcoin pushdata (instead of base64 string). The resulting OP_RETURN would look something like this:
```
OP_RETURN 19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut [ArrayBuffer from the file] image/png binary duck.png
```
By default, the encoding is `binary`, so you could just do (if you don't care about file names):
```
OP_RETURN 19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut [ArrayBuffer from the file] image/png
```
Another example:
```
OP_RETURN 19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut [ArrayBuffer from the file] text/html UTF-8 index.html
```
<br>
## 2. Referencing Media
Once uploaded, this media can be referenced from ANY other transactions using a transaction hash. For example, let's say the media hash for an image uploaded this way was `46e1ca555622e73708a065f92df0af2cc0fe00ed1dd352d5fb8510365050347c`.
You can reference it in another HTML file like this:
```
<html>
<body>
<img src="b://46e1ca555622e73708a065f92df0af2cc0fe00ed1dd352d5fb8510365050347c">
</body>
</html>
```
Of course, to upload this HTML file itself, you would do this:
```
OP_RETURN
19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut
<html><body><img src="b://46e1ca555622e73708a065f92df0af2cc0fe00ed1dd352d5fb8510365050347c"></body></html>
text/html
UTF-8
example.html
```
Once this HTML file is uploaded to Bitcoin, and the tx hash is `e2be88f33d98074f778ddd94c13fe500cb1f5a4dfb3ed958391c95f431c20549`, you can link it from another HTML, like this:
```
<html>
<body>
Check out <a href="b://e2be88f33d98074f778ddd94c13fe500cb1f5a4dfb3ed958391c95f431c20549">my website!</a>
</body>
</html>
```
You can use it in a markdown too:
```
[Here](b://e2be88f33d98074f778ddd94c13fe500cb1f5a4dfb3ed958391c95f431c20549) is a website, which contains the following image:
![image](b://46e1ca555622e73708a065f92df0af2cc0fe00ed1dd352d5fb8510365050347c)
```
Of course, you will upload it like this:
```
OP_RETURN
19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut
[Here](b://e2be88f33d98074f778ddd94c13fe500cb1f5a4dfb3ed958391c95f431c20549) is a website, which contains the following image:\n![image](b://46e1ca555622e73708a065f92df0af2cc0fe00ed1dd352d5fb8510365050347c)
text/markdown
UTF-8
README.md
```