Skip to content

Postr showcases a Twitter-like decentralized app where tweets are stored anonymously on the blockchain.

License

Notifications You must be signed in to change notification settings

kalyncoose/Postr

Repository files navigation

Postr

Shield Shield Shield Shield Shield

builtwith.png

Postr showcases a Twitter-like decentralized app (dApp) where Tweets are stored anonymously on the blockchain.

Abstract

Social media platforms are said to be the "town square of the 21st century". Millions of people rely on news and opinion from these platforms every day, which introduces a new problem of consolidated power over information. Ethereum Co-founder, Vitalik Buterin, proposed that the blockchain could be used to create a censorship-free platform. Postr demonstrates this idea with the ability to send, store, and read a message entirely on the blockchain by using smart contracts.

Demo

demo.gif

How does it work?

howitworks.png

Where's the Blockchain?

The blockchain for Postr was setup and tested in a local Ethereum Testnet using Ganache. It communicates over an RPC Server at http://127.0.0.1:7545. The gif below shows the accounts, blocks, transactions and contracts associated with the Testnet. The Post contract is what initiates the "tweet" and stores the message on the blockchain. For example, you can see the hex stored is 0x746573742061626320313233 which translates to test abc 123 in UTF-8.

testnet.gif

What's a Smart Contract?

The smart contract is the primary mechanism for interacting with the Ethereum blockchain. A smart contract can store information, compute business logic, communicate with external applications, or even chain smart contracts together to create robust end products. Postr has only one smart contract called Post where it stores a message as a type string and emits an event. This is as simple as it gets.

contract Post {
    event StorageSet(string _message);
    string public storedData;
    
    function post(string memory x) public {
        storedData = x;
        emit StorageSet("Posted!");
    }
}

Ethereum smart contracts are written in Solidity, a high-level Object-Oriented language which is statically typed. This means that contracts are first written, compiled, then deployed to the blockchain. Web3.js allows the Vue.js app to communicate to the Testnet and invoke the smart contract's post() method. By doing so, it creates a Transaction Hash which can be used to query the blockchain for the transaction.

Considerations

Postr was created as an exhibition to show the potential of a decentralized social media platform. Currently, Ethereum 1.0 requires a small gas fee in order to submit smart contracts to the blockchain. This gas fee is used to compensate the miner with a reward when the block is processed. This system is called "Proof of Work," but Ethereum 2.0 will move to a staking model. The new staking system should bring the barrier-to-entry to a minimum, where currently paying a fee to post a message is not a viable model.

Upgrades

Future upgrades to Postr may include:

  • Integrate InterPlanetary File System (IPFS) to post decentralized media content, such as images or videos
  • Add the ability to post multiple messages, dynamically creating a list of posts
  • Create a NoSQL database to store Transaction Hashes, which can be used to dynamically populate posts
  • Provide Gravatar option for users to help recognize each other
  • And much more

A separate ReadMe file will be created with a complete tutorial on how to setup Postr for local development.