Moloch V2 Subgraph for The Agency
Welcome to FlatLand: http://manifesto.designerdao.eth.link/
Broke: graphprotocol is an event sourced database. You write handlers that are triggered by events that smart contracts fire, and contain biz logic which in turn writes state changes to a SQL database.
(the logic is essentially transpiling the Moloch contract logic to TS so should look familiar)
The SQL Data is exposed as entities defined in a gql schema file and served from a GraphQL endpoint exposed by the GraphProtocol which can be queried using the graphqlAPI
Woke:
- Clone the repo and create a GraphProtocol account
- Grab access token from dashboard, create a new subgraph
- cd into the repo and login on the cli using access token
- Set up truffle config and .env file for keys you'll use and network/infura endpoint
- Set up deploy config on migration file and run: truffle deploy
- Add contract address to subgraph config
- Modify package.json to deploy to your subgraph from (2)
- yarn deploy
- Go to the subgraph explorer and type this into the query field:
{
moloches(first: 1) {
totalLoot
totalShares
summoner
summoningTime
depositToken{
tokenAddress
}
members{
memberAddress
delegateKey
shares
loot
tokenTribute
didRagequit
tokenBalances{
tokenBalance
token {
tokenAddress
whitelisted
}
}
}
proposals{
proposalId
proposalIndex
applicant
memberAddress
proposer
proposer
sponsored
sponsor
sharesRequested
lootRequested
tributeOffered
paymentRequested
paymentToken
startingPeriod
tributeToken
yesShares
noShares
newMember
trade
whitelist
guildkick
cancelled
details
}
guildTokenBalance{
tokenBalance
token {
tokenAddress
whitelisted
}
}
escrowTokenBalance{
tokenBalance
token {
tokenAddress
whitelisted
}
}
}
}
- Hit run
- Grab the graphQL endpoint from subgraph explorer and query on dapp using something like Apollo
- ???
- Profit