Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ziegfried/peepeth-subgraph
Subgraph for Peepeth, the blockchain-powered social network
https://github.com/ziegfried/peepeth-subgraph
assemblyscript blockchain ethereum graphql ipfs peepeth the-graph
Last synced: 2 months ago
JSON representation
Subgraph for Peepeth, the blockchain-powered social network
- Host: GitHub
- URL: https://github.com/ziegfried/peepeth-subgraph
- Owner: ziegfried
- License: mit
- Created: 2019-05-10T12:31:22.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T22:11:55.000Z (almost 2 years ago)
- Last Synced: 2024-07-29T16:58:25.619Z (5 months ago)
- Topics: assemblyscript, blockchain, ethereum, graphql, ipfs, peepeth, the-graph
- Language: TypeScript
- Homepage: https://thegraph.com/explorer/subgraph/ziegfried/peepeth
- Size: 2.44 MB
- Stars: 3
- Watchers: 3
- Forks: 3
- Open Issues: 33
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Peepeth Subgraph
This [subgraph](https://thegraph.com/explorer/subgraph/ziegfried/peepeth) sources events from [Peepeth](https://peepeth.com), the the blockchain-powered social network.
## Example query
```graphql
{
# 5 lastest peeps
peeps(first: 5, orderBy: number, orderDirection: desc) {
number
content
timestamp
# Get some account info from the author of the peep
account {
name
realName
}
# Get message this peep is sharing
share {
content
account {
name
realName
}
}
}
# Get total number of accounts and peeps on Peepeth
peepeth(id: "global") {
numberOfPeeps
numberOfAccounts
}
}
```## Demo App
Check out the demo app, which uses the subgraph to show some Peepeth accounts, their followers and peeps.
See it live here: [https://peepeth-subgraph.sigi.dev/](https://peepeth-subgraph.sigi.dev/)
Find the sources and some more info in the [/demo-app](/demo-app) folder
## How Peepeth works
For a high-level overview see [https://peepeth.com/how](https://peepeth.com/how).
Basically peepeth uses a [stateless smart contract](https://medium.com/@childsmaidment/stateless-smart-contracts-21830b0cd1b6) where (arguments to) method calls point to JSON blobs on IPFS. The transaction is submitted and signed by the user.
```
Ethereum Tx IPFS File
+---------------------+ +----------------------------+
| createAccount( | |{ |
| name: "Hugo", | | "realName": "Hugo Foobar",|
| ipfsHash: "Qm..." +--------->+ "location": "Somewhere", |
| ) | | ... |
+---------------------+ |} |
+----------------------------+
```Most actions can be performed this way, see [ABI](abis/Contract.json) for details. Some actions do not have corresponding JSON data in IPFS (follow/unfollow for example).
### Batched actions
To reduce cost, Peepeth allows the user to batch a number of actions and submit them at once. In this case the ethereum function call points to a JSON blob in IPFS that contains a list of actions (which can in turn point to JSON blobs in IPFS).
```
Ethereum Tx IPFS File 1
+-------------------+ +--------------------------------+ IPFS File 2
|saveBatch( | |{ | +---------------------------+
| ipfsHash: "Qm..X"+--->+ "batchSaveJSON": [ | |{ |
|) | | { "follow": { "followee": "0| | "type": "peep", |
+-------------------+ | { "peep": { "ipfs": "Qm...J"+---->+ "content": "hello world",|
| ] | | ... |
|} | |} |
+--------------------------------+ +---------------------------+
```### Signed actions
See
- [https://peepeth.com/a/free](https://peepeth.com/a/free)
- [https://medium.com/coinmonks/evolution-of-decentralised-social-media-dfe567d23e54](https://medium.com/coinmonks/evolution-of-decentralised-social-media-dfe567d23e54)Basically allows users to perform actions for free. User sign action(s) and a central service submits signed batches for all users to the blockchain.
Similar to regular batch, signed actions are stored in JSON documents on IPFS, pointing to other IPFS hashes. The user creates a signature of the IPFS hash of the actual action document using ethereum-style elliptic curve cryptography (`eth_sign`).
## Subgraph Schema
### Account
An account is a peepeth user, bound to an ethereum wallet
Field
Argument
Type
Descriptionid
ID!The account ID is the ethereum wallet address of the user
number
Int!Accounts are numbered in the order they were created
name
String!The username
ipfsHash
String!IPFS of the account info
info
StringTagline of the user
website
StringThe users website
location
StringGeographical location of the user (not in a particular format)
realName
StringThe users real name
avatarUrl
StringUser avatar image
backgroundUrl
StringUser background image
messageToWorld
StringShout it out there
followers
[Follower!]!List of followers of this user, for example
```
followers {
account {
name
}
}
```following
[Follower!]!List of peepeth this account is following, for example
```
following {
followee {
name
}
}```
peeps
[Peep!]!List of peeps by this account
createdInBlock
Int!Number of the ethereum block this account was created in
createdInTx
Bytes!Hash of the ethereum transation this account was created in
createdTimestamp
Int!Timestamp of the transaction this account was created in
updatedInBlock
IntNumber of the ethereum block this account was last updated in
updatedInTx
BytesHash of the ethereum transaction this account was last updated in
updatedTimestamp
IntTimestamp of the transaction this account was last updated in
### Follower
A follower connects two accounts in a directed fashion.
It persists the information of an account following an followee-account.Field
Argument
Type
Descriptionid
ID!A combination of the two account IDs
followee
Account!The account being followed
account
Account!The account that is following
timestamp
Int!Timestamp when the follow action occurred
createdInBlock
Int!Number of the ethereum block this follow action ocurred
createdInTx
Bytes!Hash of the ethereum transaction this follow action ocurred
createdTimestamp
Int!Timestamp of the transaction this follow action ocurred
### Peep
A post made on the Peepeth social network
Field
Argument
Type
Descriptionid
ID!The Peep ID is the IPFS hash from where the data was retrieved
number
Int!Peeps are numbered in the order they are processed
type
PeepType!Type of the peep, allows to distinguish between regular peeps,
peeps that share another peep, and replies to other peepscontent
String!The content (message) of the peep
pic
StringA picture associated to the peep
account
AccountThe author of the peep
timestamp
Int!Timestamp when the peep was created
share
PeepThe peep shared by this peep. This is null in case this is not of type=SHARE
replyTo
PeepThe peep which this peep is the reply to. Thi is null in case this is not of type=REPLY
replies
[Peep!]!List of all reply-peeps to this peep
createdInBlock
Int!Number of the ethereum block this peep was created in
createdInTx
Bytes!Hash of the ethereum transation this peep was created in
createdTimestamp
Int!Timestamp of the transaction this peep was created in
### Peepeth
Global stats about Peepeth, use Peepeth(id: "global")
Field
Argument
Type
Descriptionid
ID!There is only one entry with `id: "global"`
numberOfAccounts
Int!Total number of Peepeth accounts
numberOfPeeps
Int!Total number of peeps
numberOfPeepsNotFound
Int!Number of peeps where the data in IPFS could not be located
## Enums
### PeepType
Type of a peep to distinguish replies, shared peeps and regular peeps
Value
DescriptionPEEP
A regular peep
SHARE
A peep sharing another peep
REPLY
A peep as a reply to another peep
## Known issues
- Not not all peeps, accounts, followers are recorded correctly by the subgraph in cases when IPFS reads time out: [graph-node issue](https://github.com/graphprotocol/graph-node/issues/963)
- Signatures from signed actions are currently not verified, since there is no easy way to perform this in assembly script: [graph-ts issue](https://github.com/graphprotocol/graph-ts/issues/63)
- `changeName` actions are currently ignored due to some transactions in mainnet causing the subgraph to crash: [graph-node issue](https://github.com/graphprotocol/graph-node/issues/932)