Blockchain CBSA – Bonus Lectures Part 2
- Bonus Lecture -R3 Corda Whiteboard
In this whiteboard. Let’s go through a transaction lifecycle. This is going to be between its creation and the inclusion to the ledger. Now up here we have the three states that will occur. The first date that has to happen, especially if you’re going to be using the API, is to understand that the transaction lifecycle has three specific states. The first is the transaction builder. This is going to be essentially creating the transaction. This is going to be step one. Now, step two actually is multifaceted.
That’s where it’s going to resolve and inspect the transaction. This essentially is going to be the signed transaction phase where the transaction will have one or more signatures. This will help make it immediately. But then after the transaction may be passed around to collect additional signatures, depending on how many notaries and nodes that are on the ledger network itself.
So for example, we’ll have it occur here and then it would occur here as well. So basically, it will be dropped off here to this note, to this node over here. And again, I didn’t highlight what services each of these are running, but just as an example, this transaction will be resolved and then inspected.
Assuming that signatures are fine, it’ll move on. Then the third step is where it’s going to actually be sent out to be recorded to the ledger. And that would be the third step right here. Now again, you could see that the transaction is signed here, it’s built over here, and then the ledger transaction has helped facilitate it over here. These are the three main stages for the API to basically be in one of these three states. Essentially three states. Again, the first is going to be the transaction builder. The second is going to be the signed transaction.
And then the third is the ledger transaction. Now, the ledger transaction will be considered resolved, especially when all the inputs have been converted to the actual states that they’re supposed to be and they’ve been fully inspected. Lastly, remember too that there’s different components to the transactions.
You’re going to have different states, different commands, and also possibly different attachments that could be part of that as well. Also note that when you do have a time window that there’s typically a notary as well that’s involved. But in a nutshell, these are the three parts of a transaction lifecycle. Let’s move on to the next I’m module.
- Bonus Lecture – Demo – R3 Corda Demobench
I’m over here at the R three quarter documentation site and I’m specifically at the Demo Bench basically page it’s under Tools on their documentation website. Now Demo Bench is basically a desktop app that you can download for you to assemble, essentially train on, run demos, on, play around with, so on and so on. Now again, the goal of being able to run a standalone desktop app is that you don’t have to download like a full blockchain. You could play around to figure out how exactly it’s going to work for demo purposes. It’s beautiful because it really does show how the blockchain could work. You have the ability to upload D apps, core DApps, that is the proper term.
But anyways, let’s go ahead and go through how this would work. The first thing is I’d recommend and the link is in the resources, go over here to Tools and read about Demo Bench. And then what you want to do is go over here to Quarter Website and download Quarter Bench. So you select Demo Bench and it’s available for Windows and it’s available for macOS and it goes through. Again, how this work gives you some examples. I already have it installed locally. And so what I’m going to do is I’m just going to go ahead and spin up my version of Demo Bench that I already had available.
And so I’m going to go ahead and make sure it’s in the window and resize this as appropriately as I can so that the resolution is as good as I can get it. Okay, so when you start Quarter Bench, you go to a default config. That’s assuming that you start at the first time. Now you have the chance to save the config that you had set up if you want. Now, as you can see, I had a notary note set up for Rome and I already uploaded a test called Corda Finance and that’s a Java file basically.
But what I want to do now is let’s do this. Well, the first thing we have to do is if you notice the new node hasn’t been fully configured per se or started. So what I want to do first is I got to start the node and you’ll see that it’s going to start up and it’ll take about 20 seconds at the most. And what it’s doing is it’s starting basically an Oracle Java virtual machine in the background. And if you just go help, you go help. What I want to do though is I just want to look at the version of the Java virtual machine.
So I type in JVM and then what I have to do now is I need to go over to the runtime, right? So show the runtime. So I’m going to go JVM runtime so I can see that I’m running on my workstation and Oracle Corp version two, basically runtime environment. And I could also, if I have a memory I could also go here, type in, let’s say pools. And again, it tells me the pools that were created, so on and so on. But you can play around with this. So this is actually running on a JVM.
What I want to do now is I want to start creating other nodes, and then I want to perform some transactions. Let’s go over here to add a node. Now, you’ll see, by default, it comes up with some interesting legal names. And I have the ability to, of course, change that if I want. What I want to do is call this, let’s say, just so it’s easy to identify friendly bank in New York. And then I want to put in the city, because this is important. If I have to go to New York. And the closest city is New York.
Now, I’m also going to leave the Cordia app in there. And what I want to do because remember, Corda is really meant for financial institutions, for basically transaction processing, making payments and other use cases that the institutions would have. But based in this case here, I want this bank to be able to issue US. Dollars. But because we have some friends in Europe that they do a lot of business with, we want to make sure that they could also issue basically Euros.
And then what do I have to do? I have to go start the node. And once this starts, I could go do what? I could go view the JVM, right, JVM. And then I want to look at what runtime, and you can see that I have the JVM running. The runtime is one, two. Okay, now, what I could do, you could see over here first that there’s no states in the vault, there’s no transactions, and the balance is zero. What I want to do now is I want to create one more nude. Now, let’s just clarify notary. What exactly is a notary?
Well, that’s a really good question. Essentially, a notary is going to prevent what’s called double spending. And essentially, you don’t want someone to overdraw their account, right? When you’re sending funds. If they have $100, they can only spend, what, $100? Also, too, they can also process transactions, but they could also basically be used as well to attest to right, sort of similar to validate, but they’re basically, a testing is sort of similar to what you would do with the notary service in the US. Where you go to a notary, bring your photo ID, you sign in front of them.
And what they do is they attest basically saying that that’s you. And basically the notary service is a service that’s going to provide that uniqueness attestation, that it’s actually you sending the transaction. So you have to sign the transaction. And it’s up to the notary to basically say it’s unique or not, that it’s you. So they either will sign it or they’ll reject it. Those are generally the two things that a notary can do, at least in quarter. Okay, so what we want to do now, so we know what a notary is, and then if we go over here, we still need another bank.
Because what I need is I have to create another bank so that I could send funds from one bank to another. Remember, the notary is there for basically preventing double spend. So let’s go over here to the Friendly Bank and add a node. Now what I want to do, let’s make this geographically dispersed, is I want to call this the bank of, let’s say Singapore. Okay. This is the Friendly Bank of Singapore. And what do I want to do? I’m going to go select Singapore from the list and they could issue US. Dollars and they could also issue Euros. And then what do I have to do? I have to start the node. So what we want to do now is I got to have two nodes up at least.
I need a notary. And then I want to send a transaction from either New York to Singapore or Singapore to New York. And let’s just validate that our VM is good to go. And again, what is it? JVM. And then I’m going to type what is it? Runtime. And again, same version, so on and so on. Good deal. Now let’s go view the database. Now the database is actually going to pop up right here. Let me go ahead and place it. And this is running SQL. So you could see that this is running essentially SQL, right? Execute current SQL statements. You have all these other statements, right? This is SQL.
As of right now, I have the ability to run SQL queries. Let’s go ahead and hold off on that. And let’s go back here so you can see the database. Now let’s go ahead and launch the Explorer. Now when I launch the Explorer, this will pop up another window and I could view transactions that have occurred in the network itself. Now when I go here, you can see that there’s no transactions, nothing in the treasury. I go to transactions here and you can see that there’s no transactions.
That makes sense, right? Now let’s go to cash because we didn’t do anything yet. I’m just showing you so you could see what we have. Now let’s go to the network. And when I look at the world map, you can see let’s go ahead and minimize this. Or actually it’s hard to see here. And you can see I have the Friendly Bank of New York. I have the notary over in Italy, and I have the Friendly Bank of Singapore out in Singapore. So it gives me this world view. And then what I could do is I could exit from here if I want.
But I want to just show you one more thing here. And you can see it tells me my identity because by default, I was in the bank of Singapore. So you have to pay attention to where you’re located, of course, tells you the Notary location, and then it tells me my peers. What I want to do now is go over to Settings. And if I wanted to, I could change the reporting currency. I could also have it point to another node if I want. But let’s go back to the dashboard so we don’t see anything going on here. So we got to fix that. Let’s go over here to exit the Explorer.
So now I’ve exited the explorer. Let’s go over to Notary and the friendly bank in New York and Singapore and just validate what we see. Okay, so now what we want to do is I need to send some funds from, let’s say, the friendly bank in New York to the friendly bank in Singapore. So the first thing, though, is I’ve got to go and issue some funds so that I could send those funds. Okay, let’s go ahead now and go over to the bank in New York and validate that the machine is running and it is.
Okay, now what we want to do is I’d like to send some funds from bank of New York to the bank of Singapore. Now, to do that, I have to go over to the Explorer. So I select the Explorer. And essentially the Explorer is a graphical user interface, a Gui. Let me go ahead and fix the screen here that is going to allow me to view my network.
It’s going to allow me to view my peers and also initiate transactions as well. Now I go to the dashboard. You can see that there’s zero transactions and there’s nothing in the treasury as well. What I want to do now is I need to go over to cash. So what I want to do is I want to act like a central bank. And the way you act like a central bank is you’re going to create a new transaction, and the transaction type would have to be issued.
Now, I’m going to issue the funds out of nowhere. Basically, I don’t have any funds, but I’m going to go ahead and create money digitally, sort of like a central bank. But just no pun intended. But what I want to do now is the issue is going to bank in New York and the one that’s going to receive the funds is going to be the Friendly Bank of Singapore.
Now, the currency will be in US. Dollars, and the amount is, let’s say, $100,000. And what I want to do is execute that. And when you’re looking, you can see in the back here, you should see a transaction occur pretty quickly. And it did. It was really fast. And you could see that the ID of the transaction is there. So it issued the cash. Well, let’s go validate that. Let’s go to transactions and what you see here is that the issuer was the bank of New York. And the command is here $100,000. And then what happened was that it moved that $100,000 from the bank of New York to the bank of Singapore. And if I go here and I expand, you can see that the cash that was received, this is the transaction ID. The signatures are down here. And basically it went from the bank of New York to the bank of Singapore. Now let’s go back to the dashboard. And you can see that when I issued that cash, that created two transactions.
Remember, when you issue funds, it’s got to take the funds out of nowhere and place them into the bank that’s going to send the money. The bank that receives the money basically is another transaction. So you can see that there’s two transactions here. So pretty straightforward. So what we did is we just used a very simple blockchain application to initiate a transfer via basically an interbank application.
Go back here. I have two transactions. Now let’s look at the treasury. Well, there’s no funds in the treasury. And if I wanted to, what I’d have to do is I could go ahead and issue funds again. I could do this either way from the friendly bank of New York to New York. I know it sounds stupid, but again, this is how it works in real life anyways, and I want it in US. Dollars.
And then I could put in a reference. So I execute it and you see the transaction occur. And you can see that in the treasury there’s basically $100,000. Go back to the dashboard. You can see that there’s four transactions. And you can see now that there’s activity in the treasury as well. So what we’ve done is we essentially created two peers. And basically those peers, basically one peer sent money to another peer. And then the bank of New York essentially created additional funds and issued it to itself.
Now, what about if I go back here and go to cash and I want to send another transaction? I could go ahead and pay because the bank of New York has funds issued to it. I don’t have to go and issue funds to New York. I could just pay from it. And then Singapore issuer currency is in US. Dollars. And it says here’s the funds available. But let’s say I just want to do something simple. $120,000 out of twelve. What is that? Let me just make sure. It’s pretty hard for me to see with this.
Okay, $12,000, right? Out of what is it? $100,000. It’s hard to see the zeros, at least on my end. Okay, so I go ahead and execute that and you can see that it paid the cash. And now I have from that $100,000, there’s $88,000 left. So that makes sense, right? So 12,000 left my treasury and got sent to the bank of Singapore. So that’s our three quarter demo bench. You can see the transaction also issued as well. Pretty nice utility. Go over to Demo bench and download it again. The Windows installer is here. There’s a macOS installer here. I would advise you just to read the instructions. And there’s also some good videos on how to run it as well on YouTube.