Posting
Action: twetch/post@0.0.1
Each Twetch post data is placed into an OP_RETURN output of a Bitcoin transaction.
Fields 0-6 implement B:\\
Fields 8-27 implement MAP
Fields 23-32 implement AIP
The protocol for posting is as follows, where each field is separated by a space.
Pos. | Example value | Description | Notes | |
---|---|---|---|---|
0 | 0 | OP_FALSE opcode | We write OP_FALSE so that OP_RETURN returns false so the script terminates by returning false and makes the output unspendable. | |
1 | OP_RETURN | OP_RETURN opcode | Returns the value on top of the stack, in this case false so that script interpreters will effectively terminate the script and process nothing afterwards. | |
2 | 19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut | B:\\ protocol prefix | ||
3 | Hello World! | Content of post per the B:\\ protocol | What displays on Twetch. For branches, append the URL of the twetch transaction being branched. Any prepended text quotes the branch. | |
4 | text/plain | Media type | ||
5 | text | Encoding | ||
6 | twetch_twtext_1601390040084.txt | Filename | ||
7 | Pipe character | Protocol boundary | ||
8 | 1PuQa7K62MiKCtssSLKy1kh56WWU7MtUR5 | MAP protocol prefix | ||
9 | SET | Setting values | ||
10 | tw_data_json | |||
11 | null | JSON object representing metadata of a Tweet | Default null | |
12 | url | |||
13 | null | URL reference or URL of Tweet if tw_data_json is populated | Default null | |
14 | comment | |||
15 | null | Default null | ||
16 | mb_user | |||
17 | 523 | MoneyButton User ID, optional | Default null | |
18 | reply | |||
19 | null | Transaction ID replying to | Default null | |
20 | type | |||
21 | post | Type of Twetch (post or reply ) | ||
22 | Timestamp | |||
23 | null | Default null | ||
24 | app | |||
25 | twetch | Default twetch | ||
26 | invoice | |||
27 | 5d3fe61f-3541-404a-97ef-21e4a917dd39 | |||
28 | Pipe character | Protocol boundary | ||
29 | 15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva | AIP protocol prefix | ||
30 | BITCOIN_ECDSA | Signing algorithm | ||
31 | 1HCtG4in4yscc5FsEWyREKNk2dmj9LgMHE | Signing address | Address tied to MB or RelayX paymail, any address setup at the Twetch Developer page, or the m/0/0 derivation path of keys tied to seed phrase | |
32 | LXHxuOWmCDkSer3NeaRA0UWcTW+b+iimvR5KNaxuVTpxHcL XtihnWTWXxBpkRz2GfvNg/sb23A4n6NAP/YoGBQm8I= | Signature of SHA256 hash of an ArrayBuffer of fields 2-28** | Sign using private key of address from 31 |
**The process outlining how to sign Twetch data is detailed here.
Posting Tweet data
Background
Archiving Tweets to the Bitcoin ledger was one of the first use cases of Twetch.
As such, Twetch has designed a custom schema to map Tweet data and interpret on the site.
Below are the fields along with an example.
Tweet mapping
created_at – Timestamp tweet posted
twt_id – status ID of tweet (end of tweet URL)
text – content of tweet
media – array of tweet media URLs (photos, gifs, videos, etc.)
user
name – Name of twitter account
screen_name - @handle
created_at – Timestamp user account was created on Twitter
twt_id – ID of user from Twitter’s API
profile_image_url – URL photo reference of user’s profile picture
Map the URL of the tweet to the url value field 13 above.
Example:
{
"created_at":"Mon Jul 01 12:51:57 +0000 2019",
"twt_id":"1145676412512116736",
"text":"I can't wait for the memes and comments! @CryptoHayes @SatoshiLite @justinsuntron @cz_binance ",
"media": [
"https://pbs.twimg.com/media/D-ZCiJfVUAAp7tQ.jpg"
],
"user":{
"name":"Ran Neuner",
"screen_name":"cryptomanran",
"created_at":"Mon Jul 20 14:33:19 +0000 2009",
"twt_id":"58487473",
"profile_image_url":"http://pbs.twimg.com/profile_images/1256349871197437953/zIY5Puew_normal.jpg"
}
}
https://twitter.com/cryptomanran/status/1145676412512116736
The above is an example for Tweet data, but other metadata formats can be supported.
The URL field determines how the metadata should be structured.
To have other metadata formats for different domains/URLs supported, please reach out to @1 & @4 via Twetch Chat or email at hello@twetch.com.
BitcoinFiles
To post files, include a BitcoinFiles URL reference to the file in the content of the post.
Example:
https://www.bitcoinfiles.org/t/161064d12ee1b8441ca26bdd343eb37d8153ee72fb8263bfe2dd5392e0e8b2e7
Currently, the following file types are supported:
- Images (ex. png, jpg)
- Gifs (.gif)
- Audio (ex. mp3)
- Video (ex. mp4)
Paying for files via a Twetch
Alternatively, users can include a P2PKH output that pay to an address for BitcoinFiles for each file.
If those addresses spend to create BitcoinFiles per the B:\\ protocol, then those files will be rendered on Twetch.
Up to 4 files (images) are supported in this manner when rendering on Twetch.
Example Twetch transaction that pays for 4 BitcoinFiles images:
https://bitcoinfiles.org/tx/3ea715fb2ff489dfe9af246499ea423a644040202c2b3503038a45646abce214
BitcoinFile transactions:
https://bitcoinfiles.org/tx/460cc0444c18b1152f4c6d5d77786bda3994dea8b06589e31d0c6e5c8a2d243e
https://bitcoinfiles.org/tx/457f7a10bc108121c315fdda90a31febdd600f44090e473f6684142eb0a4038b
https://bitcoinfiles.org/tx/53df1e86f06ca2966bf19eb13839cf5d21291820c1ad3481c8575f237f0f3c57
https://bitcoinfiles.org/tx/3f0151845da08da62cbede87e5bc2ed99edb9f49bae7a436052a6b1842d41fc8
Commands
In posts, Twetch supports several commands that pay users directly, set or remove a troll toll or initialize a poll with voting options.
To detect commands, the posting logic matches against various regular expressions that can be found here.
/pay
To pay a user on Twetch, include the following syntax in the content:
/pay @<twetch_user_number> $<USD_amount>
Example:
/pay @145 $2.18
In addition to Twetch user numbers, /pay supports Handcash handles, paymails and addresses.
Example:
/pay jdh7@simply.cash 1BwxZcZUnkKW1UmEnkd4F3YcCvett5Kk7 $jdh7190 $0.09
The pay amount will be divided evenly among each payee. Each payee will receive $0.03 in the example above.
/pay supports satoshi amounts as well.
Example:
/pay @1 2.13800007 BSV
*/pay only supports USD and BSV at this time
/trolltoll
To set a troll toll on a user, include the following syntax:
/trolltoll @<twetch_user_number> $<USD_amount>
/trolltoll @7346 $2.18
To remove an existing troll toll on a user:
/trolltoll remove @<twetch_user_number>
/trolltoll remove @2
/poll
To create a poll, append the following syntax to the content:
/poll [option1, option2,…,option5]
Example:
/poll [yes, no, wat?]
Polls have a maximum of 5 options.
Mentions
To mention a user in a Twetch post, add @ before their user number.
Example:
proud of y'all man - this experience has gotten so much better over time and I know it's bc y'all are putting in work. keep going. h/t @1 @2 @3 @4 @5 @78 and others
The user will receive a notification and be paid 0.5 cents of Bitcoin in a P2PKH output.
Payees are explained in the Fetching payees/outputs section.
Hashtags & Cashtags
For each hashtag or cashtag in a post, a 21e8 mining script is added as an output. See here for more details.
Execute a SHA-256 hash on the hashtag, and prepend the script with the hash, along with the target difficulty.
Hashtag example:
<sha256 hash of #twonks> <21e8 + target string in hex> OP_SIZE OP_4 OP_PICK OP_SHA256 OP_SWAP OP_SPLIT OP_DROP OP_EQUALVERIFY OP_DROP OP_CHECKSIG
Cashtag example:
<sha256 hash of $TWNKS> <21e8 + target string in hex> OP_SIZE OP_4 OP_PICK OP_SHA256 OP_SWAP OP_SPLIT OP_DROP OP_EQUALVERIFY OP_DROP OP_CHECKSIG