Project discussed on the Gitcoin Governance Forum here.
[00:00:00] Ladies and Gentlemen, welcome to another instalment of demo days, I guess. This is about the Gitcoin conviction voting dApp that we've been building in the last couple of weeks. I have a few updates that I wanted to share and video updates are the best. So here we are. It's deployed, you can play with it.
[00:00:23] Most of you, at least Austin, Kevin. I think you should already have the fake Gitcoin tokens from Rinkeby. If you don't, you can go and check on the "readme" file for the repository and you will see where the contract address is. You can use it to mint yourself some tokens.
[00:00:44] Let's get to the demo. This is the app, it looks like pretty much what it looked like before. What changed is, search is now truly random. What I mean by that is before we were fetching the first 50 results from the database and we were shuffling them in browser. It wasn't truly random. The first 50 results were always the same 50 results, just in a different order. Right now they're not so if you scroll down, or even if you look at the first 15, those are completely random. If you scroll down, though, we keep your seed constant through pagination. So you will not get the same result twice, as long as you keep going. If you come up and for example, you refresh the page, you will get new results because, when you refresh the page, you get a new seed.
[00:01:40] So essentially you're not going to get the same order you had before. If you search for something like "scaffold", you get these things. There is, oh, scaffold-eth. And if you could scroll down, these would behave in the same way. And by the way, we can debate whether we want the search results to be still shuffled randomly, or do we want them to somehow have an accuracy sorting of, of, of sort?
[00:02:10] I'm not sure we can discuss that, but anyways here, even if I, for example... This should re-trigger and I wasn't slow enough. If I do this... There we go, see it's the same stuff but in a different order. Now, if I completely delete these, I will get a different sorting order here too, because it is a new seed.
[00:02:33] So all this rambling is to say results are actually truly random right now. What changed from before is the gas optimisation in the contract. So right now, all operations are cheaper. And so you can add to cart. I'll go through this to show what the use their experience is. And I will cut the pauses while we wait for MetaMask and Rinkeby to do their thing... that was actually fast.
[00:03:07] We should disable this confirm button while the transactions are going.
[00:03:11] Okay, success. Let's go to home. Up here in your dashboard, you will see... there you go. You will soon see the tokens you just staked. Now, another thing that's missing is we're not giving any indication to the user of how much their tokens are worth over time. We might want to show either an incremental number, but what I'm thinking is actually like a tiny, small, little graph, that goes up with the value. I don't know, something nice, something well-refined. We can decide what we want to do. Point is now you can un-stake in bulk, which is another strategy to save on the cost. The thing to consider is that while you can stake multiple times for the same grant, for example, let's pick this one and stake again.
[00:04:04] I have one GTC here, I'm going to drop another one on this. While you can do that when you're staking, when you go and un-stake or release your tokens, it's actually all or nothing per each grant. So. That's interesting amount exceeds allowance. Let me try it again. Confirm.
[00:04:30] And that succeeded, so I don't know what happened there. Now here you should see these become 2. Give it a second. And we should also give some indication to the user that these results are going to be slightly delayed. They're not going to be, there you go, real time. So there's still some improvements to make in terms of UX. What I was saying though, now if I want to un-stake from these ones, I have to un-stake all two GTCs.
[00:05:08] I can not say I just want to un-stake 1.0 or 0.5. But I do that in batch, which does save on gas as well.
[00:05:20] Okay. Transection succeeded. And then when the transaction succeeds, after not too long, these two records should disappear.
[00:05:30] There we go. Okay. Another thing that changed from before is where we are getting these results from. I tried to use the events and parse them, like we do usually with scaffold-eth, but it wasn't working on Rinkeby and I think it's because the eth-hooks library that we use is too outdated in the repo.
[00:05:51] So instead of updating that to the latest version which we probably should and actually, I think I asked in the chat and it's already been worked on, what I did is I created a subgraph. So this is on Rinkeby, obviously, this is our API end-point, and this is the ID of the sub graph. I have in the read me a few interesting queries. They're not very nicely written my address is hard-coded. But you can use them and you can see what is going on. So we're keeping track of a few different things. We're keeping track of the votes and what we call releases in the contract, which essentially means every time somebody withdraws, how much they do withdraw and from which, um, I think grants, let's see "getVotesByVoterID".
[00:06:47] The votes have the ID, voteId, amount and grantId. So we know when, who, and how much on what. Don't know why I said it like that. And if we look at the "releasesByVoterID", we know, okay, this is an ID. We know. How much, and what was the initial vote that we are deleting. And if you do it in bulk, you actually releasing from two different votes essentially, you create two records here cause you've fire two events.
[00:07:21] In example we just looked at where I voted twice on one grant and then I un-staked, here you will see two different records. They're probably number seven, and... actually I have way more tests than that. They're probably 11 and 10. Let's see. Is it the same? Okay. I would have to go and see what the grantId is, but I think yes, one and one, I think it's this.
[00:07:47] But yes, you will see multiple events so we can reconstruct the complete history of all the votes from here. And we can calculate the conviction at any point in time based on the data that we have here. Another thing that we keep track of is the, what I called the running records.
[00:08:06] I didn't have a better name for that, but essentially this is like a record that says: this person on this grant has currently staked this much tokens. And that is actually what is used in the dashboard up here to show the set of records, as long as the total staked is not zero.
[00:08:27] So if I open here and I go "getRunningRecordsByVoterID" and I execute it, you will see a bunch of records, most of which have zero because I un-staked pretty much everything. And I also did some tests before recording this video, just to see that everything worked properly. But towards the end, there should be somewhere one that's a total staked is two.
[00:08:56] There it is, and this record is what we're seeing here. So basically the running records are a snapshot at the present time, while using the votes and the releases, we can calculate the conviction at any moment for whichever grant we want or for whichever person we want. So we can get numbers and data out of these, essentially.
[00:09:23] What else to say? This is also in the same repository, if you go into here. And by the way, should we move these a different organisations? Should we move it under scaffold-eth? Should we move it under... I don't know, whatever you guys want to do. If you come here, you will see that into packages, subgraph, this is where the logic actually is.
[00:09:48] This is the schema where I define the fields I was talking about. So we have vote, release. We have voter, of course. And we have the running vote records so per each person we can also see what they voted for and how much they withdrew. And this is the mapping logic.
[00:10:07] I think this is it. I don't think there is anything else to show for this demo. Not that I can think of.
[00:10:15] But anyways, I'm rambling. So in terms of status update, I think this is it from me. I am about to go to the airport and I'm going to be flying to New York where I will spend about a week. So I don't know how much I'm going to be able to work on this in the next few days. Um, but, if there's anything, just let me know.
[00:10:36] If I have a few moments, I will bring my laptop with me and I'll be probably doing things in my free time anyway, just because I like playing around. So if there's anything that you want me to change, just let me know. Otherwise you guys feel free to all fork the repo play with it. If you do push into my repository, it's going to get automatically deployed.
[00:10:58] So feel free to try and, um, yeah, I think this is it. We're officially blocked by Austin, which is supposed to get the contracts audited. So I'm not saying that, Austin you're blocking us, but we should get that done so we can start opening it up a little bit and maybe experimenting with a bigger a group of people. Or at least throw it on Mainnet and see what the costs are on Mainnet, see what the experience is, you know, we can stake a few GTCs ourselves and, uh, and try that. That was it. Thanks for watching. I'll talk to you guys soon.