EtherTweet

Microblogging on the Ethereum Blockchain

Decentralized Twitter

This repository contains the code of a decentralized microblogging service running on the Ethereum blockchain.

The service provides basic Twitter-like functionality to tweet messages of up to 160 characters.

Here, decentralization means there is no company or central authority in control of what is being published.

The system is censorship resistant in the sense that once a message is published, it can only be removed by the publisher.

All accounts can receive donations in Ethereum's Ether crypto currency. Being able to receive donations can be an incentive to run a decentralized microblogging feed.

To not expose the user's social graph to the world, following other accounts is not supported on purpose.

If you want to edit the source files, you can use Ethereum's Mix IDE which can be found here. In the repository, there is a Mix IDE project file called .mix, it also contains some test cases used during development. Mix can simulate a local blockchain for testing.

Install

Read Tweets in the Web Browser

You should see a menu of existing accounts and the corresponding tweets, as shown in this picture:

Using the Geth Command Line

Posting tweets is not yet supported using the web browser. Instead, you have to use the geth command line.

After starting geth as shown above, open a second shell and start the interactive geth interface by running

geth attach

Your prompt should change to >

As a test, get the status by entering:

> eth

You should see various ethereum statistics like the current block number.

All commands below assume you are in the interactive geth interface.

Read Tweets on the Command Line

An example how to read tweets of an existing account.

See section Browse Accounts below, to learn how to explore all existing accounts.

Create a local variable TweetAccount to point to the existing account. Here, the address of the test account 0x9e82d1745c6c9c04a6cfcde102837cf0f25efc56 is used. Change this address in the code block below to read tweets of other accounts.

Copy the following code block and paste it into the interactive geth interface:

Get a specific tweet. For example, get the first tweet, tweet number 0:

TweetAccount.getTweet(0)

Ether

For account creation, registration and tweeting, you have to get Ethereum's crypto currency Ether. You can either buy Ether for Dollar/Euro or trade Ether for Bitcoin. Instructions can be found here: ethereum.org/ether. For example, you can use the kraken.com crypto currency exchange.

At time of writing (December 2015), pricing is as follows:

Price of account creation and registration: 0.02384905 ether or $0.020271693 or €0,018392864 or roughly 2 cents

Price per Tweet: 0.00420185 ether or $0.0035715725 or €0.0032405508 or roughly one third of a cent

If you are curious how this ethereum byte code was created, have a look at the deploy directory in this repository. Also, have a look at the TweetAccount.sol source file, it contains a lot of comments to explain what the code does.

Post a new Tweet

Note that you have to own Ether to be able to tweet. See previous example how to check your account balance.

You should see a message like I1210 13:33:35.411646 58618 xeth.go:1028] Tx(0x8b253799a87efd08133e4f2b7dcece785a05d6de075c92435da48cb61009ac7e) to: 0x9e82d1745c6c9c04a6cfcde102837cf0f25efc56 in the geth logs.

Check:

MyTweetAccount.getLatestTweet()

Should display ["hello world", 1449750863, 1]. That means latest tweet is hello world, tweetet at unix timestamp 1449750863 with a total of 1 tweets for this account. Use a tool like unixtimestamp.com to convert timestamps.

More checks:

MyTweetAccount.getNumberOfTweets()

Should return 1

MyTweetAccount.getTweet(0)

Should return ["hello world", 1449750863, 1]

If you want to post another tweet at a later time, do the following:

Define a variable for your tweet account as described in section Reading Tweets on the Command Line.

Post a new tweet by creating a transaction with tweet.sendTransaction as descibed in this section.

Register Account Name

To make your account known to the world, give it a name and register it in the account registry.

Then, others only have to remember your account name and do not need to write down the long and complicated account address.

Create a variable for the account registry. Copy and paste the following block into the geth interface:

Register account name test for the account MyTweetAccount (from the previous example) into the TweetRegistry. Please note you have to use a different account name than "test" since it is already taken.

License

Copyright (C) 2015-2016 Jahn Bertsch
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation in version 3.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.