mowblox / emt-marketplace

The goal is to help people become really good at what they do through decentralized mentorship.
https://emt-marketplace.vercel.app
Apache License 2.0
1 stars 3 forks source link

Blockchain Event Listener #40

Open mickeymond opened 9 months ago

mickeymond commented 9 months ago

In the absence of a protocol like the GRAPH on Toposware and getLogs also failing at 1000 blocks, we want to develop a Node.js Event Listener to listen for necessary EM events emitted from the Smart Contracts and write them to Firebase.

Available Events on EM

  1. ContentAdded
  2. ContentUpVoted
  3. ContentDownVoted
  4. MentClaimed
  5. ExptClaimed
  6. ExptDeposited
  7. ExptBought
  8. ExptWithdrawn
mickeymond commented 9 months ago

@od41 @Jovells What are your thoughts still on this? Is this still in our scope of the MVP or should we rely solely on reading data from view functions in the smart contract?

Jovells commented 9 months ago

For the MVP, I think we can rely solely on reading from the contracts. Looking through the contracts, I can see that none of the events emitted contains data that is not stored within the contract. Meaning there is no information which is only stored within events. If there was, it would have necessitated something like the GRAPH, but as it stands now, I think that is not the case

mickeymond commented 9 months ago

@Jovells You are 100% right, when the time comes to rely on events then most of the stored data will be removed in favour of emitting events that will be listened to and used to update Firebase.

mickeymond commented 9 months ago

@Jovells @od41 There is also the possibility of running your own Graph Node to index whatever blockchain network you want according to the information here https://thegraph.com/docs/en/developing/supported-networks/#graph-node I think a decent Virtual Machine (2vCPUs, 8GB RAM, 50GB ROM) will be a good start to experiment with this.

od41 commented 9 months ago

@mickeymond I think that we need something like this. Nevertheless, if we can operate the MVP albeit a limited one without it like @Jovells suggests, we'll have to push it into the backlog. All priority is getting a working first version.

(Edit) I've checked out the repo for hosting/managing your own node. We can hold on to it for now and implement when we're ready.

Jovells commented 9 months ago

Putting this here for the record...

It is important to know which mentor claimed a particular set of Expts, since every Expt is supposed to be non-fungible and gives access to a specific mentor.

However, at the moment the way we are determining, within the Dapp, the mentor to whom a particular Expt gives access is by looking at the data in the database. Checking the owner of the Expts in the contract is also not reliable because when the Expt is sold, the owner is changed. A downside to this is that if a user decides to claim by interacting with the contract directly, there will be no record of the claim in the database to read from.

Another way determine the mentor would have been to get the event that was emitted when the Expt was minted but considering the fact that we do not have access to the graph on topos, that can be quite cumbersome.

We could also store the ids of the the Expts of a mentor in the marketplace contract but that would also be gas expensive

@od41 @mickeymond