Reputation:2

Recovering deleted posts

One of the reasons [Peeranha will change the world](https://peeranha.io/questions/57) is that it "gives ownership of the knowledge back to the community and preserves it by storing on Polygon blockchain and Filecoin." I would like to explore in more detail the mechanism of knowledge preservation. As a practical exercise, I would like to know how to recover / access the post about the Ministry of Happiness which at one point existed on Peeranha but no longer does. Presumably, the users / community should have all the information necessary to recover / access such data even without Peeranha's involvement. Could you provide the steps to access or recover the Ministry of Happiness post from the blockchain / Filecoin? Thanks

    Answers 1

    Reputation:1

    # Reading deleted posts from blockchain There are at least 3 ways for accessing any post ever existed on Peeranha. ### Read history of transactions This approach would work for any public blockchain. Creating a post on Peeranha requires a transaction executed on Polygon blockchain. All of the transactions are permanently recorded on blockchain and can be seen by anyone. Tools like Polygon scan allow you to see all of the [transactions](https://polygonscan.com/address/0xD68fD3afA237D0F96493c959fC150bc584b87AE4) associated with Peeranha smart contract that is responsible for execuring logic related to posts. Any historic information can be retrieved from the parsed transaction data. Peeranha uses [meta transactions](https://docs.polygon.technology/docs/develop/meta-transactions/meta-transactions/) to cover transaction fees for the users. You will see *Execute Meta Transaction* transactions a lot. These transactions are harder to parse but all required information is still recorded on the chain. ### Read Events This approach works for Ethereum, Polygon, and other EVM chains. EVM smart contracts typically emit *events*. It is up to an individual smart contract to decide when and which events to emit. Peeranha is not an exception. Events are emitted when posts are created, edited, deleted, or anything else important happens. You can see events emitted by Peeranha by looking at the [source code](https://github.com/peeranha/peeranha). Here are few examples: ``` event PostCreated(address indexed user, uint32 indexed communityId, uint256 indexed postId); event ReplyCreated(address indexed user, uint256 indexed postId, uint16 parentReplyId, uint16 replyId); event CommentCreated(address indexed user, uint256 indexed postId, uint16 parentReplyId, uint8 commentId); event PostEdited(address indexed user, uint256 indexed postId); event ReplyEdited(address indexed user, uint256 indexed postId, uint16 replyId); event CommentEdited(address indexed user, uint256 indexed postId, uint16 parentReplyId, uint8 commentId); event PostDeleted(address indexed user, uint256 indexed postId); event ReplyDeleted(address indexed user, uint256 indexed postId, uint16 replyId); event CommentDeleted(address indexed user, uint256 indexed postId, uint16 parentReplyId, uint8 commentId); ``` Deleted post will have events *PostCreated* and *PostDeleted*. Events typically do not contain full details for the objects. However, they can be used to find transactions where important event happened. Then this transaction can be parsed for details. ### Read deleted objects from smart contracts if they are still there It is up to each individual smart contract to decide how inforamtion is deleted. Peeranha follows approach of marking deleted posts with a special flag but preserving the original information. Here is the struct representing post inforamtion recorded on blockchain: ``` struct Post { PostType postType; address author; int32 rating; uint32 postTime; uint32 communityId; bool isDeleted; uint8[] tags; CommonLib.IpfsHash ipfsDoc; ... } ``` *isDeleted* flag is set to true for deleted posts. However, all other information is still there and anyone can read it from the blockchain. *ipfsDoc* stores hash of the document in Filecoin / IPFS with the content of the post. # Reading data from Filecoin / IPFS Any text content stored on Peeranha (for example text for the posts, replies and comments) is stored on Filecoin and IPFS. Information uploaded to Filecoin/IPFS can't be deleted by definition. However, it may disappear from the network over time if no one is pinning that files on their IPFS nodes or not paying for storing that information on Filecoin. We are pinning all contnet posted on Peeranha, even deleted. Soon we will be posting daily backups of IPFS data. Additionally, anyone in the community is free to pin Peeranha's IPFS data on their node if find that important. # Read Peeranha subgraph on the Graph Peeranha uses a subgraph on [the Graph](https://thegraph.com/) to index data from blockchain and IPFS for querying. You can query [Peeeranha Subgraph](https://thegraph.com/hosted-service/subgraph/peeranha/peeranha) to find deleted posts.