Twetch Developer

Twetch Developer

    ›Protocol

    Protocol

    • Introduction
    • Posting
    • Likes
    • Follows
    • Votes
    • Purchases
    • Feature requests
    • Authentication
    • Twetch API

    twetch-js

    • Overview
    • Library
    • Storage
    • Wallet
    • CLI

    Twetch Pay

    • Overview

    Encryption

    • Overview
    • Create a conversation
    • Send a message
    • Read messages

    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 valueDescriptionNotes
    00OP_FALSE opcodeWe write OP_FALSE so that OP_RETURN returns false so the script terminates by returning false and makes the output unspendable.
    1OP_RETURNOP_RETURN opcodeReturns the value on top of the stack, in this case false so that script interpreters will effectively terminate the script and process nothing afterwards.
    219HxigV4QyBv3tHpQVcUEQyq1pzZVdoAutB:\\ protocol prefix
    3Hello World!Content of post per the B:\\ protocolWhat displays on Twetch. For branches, append the URL of the twetch transaction being branched. Any prepended text quotes the branch.
    4text/plainMedia type
    5textEncoding
    6twetch_twtext_1601390040084.txtFilename
    7Pipe characterProtocol boundary
    81PuQa7K62MiKCtssSLKy1kh56WWU7MtUR5MAP protocol prefix
    9SETSetting values
    10tw_data_json
    11nullJSON object representing metadata of a TweetDefault null
    12url
    13nullURL reference or URL of Tweet if tw_data_json is populatedDefault null
    14comment
    15nullDefault null
    16mb_user
    17523MoneyButton User ID, optionalDefault null
    18reply
    19nullTransaction ID replying toDefault null
    20type
    21postType of Twetch (post or reply)
    22Timestamp
    23nullDefault null
    24app
    25twetchDefault twetch
    26invoice
    275d3fe61f-3541-404a-97ef-21e4a917dd39
    28Pipe characterProtocol boundary
    2915PciHG22SNLQJXMoSUaWVi7WSqc7hCfvaAIP protocol prefix
    30BITCOIN_ECDSASigning algorithm
    311HCtG4in4yscc5FsEWyREKNk2dmj9LgMHESigning addressAddress 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
    32LXHxuOWmCDkSer3NeaRA0UWcTW+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:

    1. https://bitcoinfiles.org/tx/460cc0444c18b1152f4c6d5d77786bda3994dea8b06589e31d0c6e5c8a2d243e

    2. https://bitcoinfiles.org/tx/457f7a10bc108121c315fdda90a31febdd600f44090e473f6684142eb0a4038b

    3. https://bitcoinfiles.org/tx/53df1e86f06ca2966bf19eb13839cf5d21291820c1ad3481c8575f237f0f3c57

    4. 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
    

    ← IntroductionLikes →
    • Posting Tweet data
      • Background
      • Tweet mapping
    • BitcoinFiles
      • Paying for files via a Twetch
    • Commands
      • /pay
      • /trolltoll
      • /poll
    • Mentions
    • Hashtags & Cashtags