A simple DAP walkthrough. So this is the backend file we're looking at here. So either player, Bob or Ellis, gets the fingers they played, and gets a guess, and sees who won the winning game. And you can see that up at the top is really, that's just the interface of the methods that are actually defined on the front end. And then also you have other participants that are involved, right?
So the end-of-the-play get fingers thrown and total guess, and publish them, and then commit means you're done. You're committing that out to the blockchain. So the backend now also continues with rules and outcome. So this is the logic to a game. I've got a game I'm gonna show you here, Mora, where you're throwing fingers and a guess between the two opponents. And if either one of them guessed it correctly, then they win that particular match. So by doing this, everyone agrees on the rules for the outcome, and everyone sees the outcome of the engine that we have.
Now on the front end, this is you take the common number of 10, for example, into whatever native platform support. So it takes like 10 algos, for example, you convert it to micro-algos. And then you have the ability to create a new test account in the Dev environment with that starting balance. And then you see down below, this is where Alice is deploying the contract. And then Bob's going to attach to the contract, in other words, opt in, and then we go ahead and run the game. And then also, these are the interact methods. So we saw the interfaces to these on the back end, and now this is the actual code in the JavaScript in the front end that this provides. So you can see, we're just using some random functions here.
Next, let's talk about verification. This is a very, very important topic. And this is what it does, is it protects against blockchain attacks. And it guarantees things like the contract balance is zero. Because think about it, you're creating accounts on the fly potentially in these contracts. And there you're funding them. And if it's created on the fly, it's in the contract, only that contract knows what the private key is, right? No one else would know that. And if the contract ends executing and there's funds still in that account and haven't been exhausted, guess what? You're gonna lose those funds. There's no way of getting at them because the contract gets done running, it goes away. And you know that's a problem, that's an issue. And there have been, you know, some big monies lost in the past because of this particular problem.
Comments