03 Running Ethereum HelloWorld demo

Learn Ethereum by Examples Part 1 Hello Ethereum world
13 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
This is a free item
$0.00
د.إ0.00
Kz0.00
ARS$0.00
A$0.00
৳0.00
Лв0.00
Bs0.00
B$0.00
P0.00
CA$0.00
CHF 0.00
CLP$0.00
CN¥0.00
COP$0.00
₡0.00
Kč0.00
DKK kr0.00
RD$0.00
DA0.00
E£0.00
ብር0.00
€0.00
FJ$0.00
£0.00
Q0.00
GY$0.00
HK$0.00
L0.00
Ft0.00
₪0.00
₹0.00
ISK kr0.00
¥0.00
KSh0.00
₩0.00
DH0.00
L0.00
ден0.00
MOP$0.00
MX$0.00
RM0.00
N$0.00
₦0.00
C$0.00
NOK kr0.00
रु0.00
NZ$0.00
S/0.00
K0.00
₱0.00
₨0.00
zł0.00
₲0.00
L0.00
QR0.00
SAR0.00
SEK kr0.00
S$0.00
฿0.00
₺0.00
$U0.00
R0.00
ZK0.00
Already have an account? Log In

Transcript

Okay, so in our previous two videos, we looked at how to create the virtual machine and I gave you the overview of the environment. Next thing we're going to do is for our demo example, now, we can open a terminal and run it from here, but you know, if you are comfortable with putty you can connect through putty as well okay. So, you know, I will use that option. In case you are not aware about what it is you can get it download it from here and it is a small utility wherein you can remotely connect to any Linux machine right. So here I have it installed. I will just use putty and then what we need to do is we need to get the public IP of our virtual machine so I will get the public IP Yeah.

Oh, yes, again, username, password, or you get connected, right. So currently, we are at the home directory. We need to go to tech stop aetherium demos, and hello world demo. So this is our directory where we have the code. So the first thing we need to do or here is we need to compile the code right now that code will get compiled and deployed on our Ethereum blockchain. But we don't have the blockchain running right.

So what I will do is I will just duplicate this session. Okay. Yeah. Okay, in, in my last session I talked about the test RTC. Okay, so that test RPC is basically in memory simulation of our aetherium blockchain. Okay.

So I will just type test RPC, and this command will come to to enter. So now, this basically is our Ethereum blockchain. a simulation of Ethereum blockchain aetherium public blockchain. So instead of being compiling our application and deploying it on the main chain, we created a simulation. And here you will see, by default, it gives you 10 different aetherium account, which you can use it for your testing purpose. Okay.

So this is running and this is the port where it is running. And in my last video, I did mention that we configured our application to connect to this code for deploying our contract. Okay, so next thing we're going to do is over here, clear the screen. I will use truffle, and migrate. So truffle framework will look into our demo folder. And it has the migration script which I mentioned in the last session.

So I hit Enter, and I would have these two windows side by side. Okay, so it will compile and here you will see it says that saving successful migration to the network. So it basically deployed our application or the contract over here. So now we have our code deployed. Next thing we need to do is we need to test this code, right. So again, it's truffle here gives us out of the box console for testing purposes right.

So wherein it gives you the API's through which we can call the contract which are deployed on our blockchain and execute the functions within the contract. So if you remember in our contract, we had well made a coin. And that metal coil has a couple of functions for getting the balance and one function for sending some amount to another account right. Now here I have some commands, which can be used to affirm our contract. Now again, here, we use a framework called web three. So now here, we use another framework called web three.

And this framework has all the API's to basically work on the Ethereum blockchain. Okay, so in our case, the etherion blockchain is our test RPC. And we can query that chain through this scanner. I told you that when we started the test net, it gave us 10 sample accounts okay. Over here we can see you have this sample accounts. So what we are going to do is in this demonstration we will, so this this is a first account, okay.

So this account will have 10,000 assigned to the balances because what we are going to do is we are going to use this account to initialize our metaphor. Okay, so let me just demonstrate it one by one. So first we can query the accounts on the tyrian by using this, but in order to execute this command, we need to open up the capital console So I will just say, truffle console, and it will open up that test console. And over here then we can execute. So we are in the truffle environment, I will just copy this corner to execute it. So this command will query our blockchain and it will return those 10 accounts.

If I hit Enter, you will see I have these 10 accounts. The same telecoms Public Accounts which are available you can see this one ends with 349. So here we have three, four. These are the same account. Next thing I'm going to do is, you remember you know, we talked about contracts in our code, one of the contracts was Mehta coin. And I said that meta coin is similar to a class in object oriented programming.

Okay, so here I will create a variable metal coin. And then what we are doing here is basically invoking that contract, okay getting it deployed for say deploy, we are going to assign that instance to this variable. Okay? So this code basically create an instance of meta coin and assign the value of that instance to our variable. So I'm just copy this paste over here. And we have the meta coin instance created.

Next thing we can do is we can get the balance of the meta coin. Now if you remember the code, the meta coin Okay, so let me just showing you the code. Some of this is 100 Let's see ditto textile slash Hello. Now here we have this constructor, right so this constructor will assign 10,000 but it will assign to the address who is going to initialize this contract. So in our case we initialized it to mate Okay. All right.

So what we'll do is through this we will call okay and you will see that it will have 10,000 Okay, so it is returning the value $10,000 Okay, but this value will be only to the first account okay because we invoked it for this account okay? The other accounts will be empty at this point. Next what we are going to do is we will create two variable representing these two accounts zero and BB. Okay, so zero is this default nine and one Is this okay? And then what we'll do is before we invoke the same coin we already query so let's query it again. The Count zero, okay.

So the balance is 10,000 because we initialize our meta coin using this account and I will call this again vit account Kumar Okay, so here, current one, and account one will be zero. Okay. Now what I'll do is I will call this same coin method on our contract. So as per our code the same coin will them since the amount I'm sending is 100 Okay, which is less than 10,000 for the sender, it will deduct from that from there and then for the receivers account it will add that value. So, this and now you get the details of the transaction. So this is the transaction, transaction hash, which block number this transaction was executed all on our test RPC blockchain, how much gas is being used for this transaction and so on.

Okay. And also on our test net, you will see the same transaction being printed. Now if we go and query our first account, comm zero you will see the balance is 10,000 minus thousand which is 900. And the benefits are low first McCarty's which was previously zero. So this is a demonstration of Ethereum blockchain. And how you know, we can deploy a contract, we can put a business logic in that contract and then we can once we deploy it in our blockchain, we can execute those contracts right.

So in our case, we had one meta coil contract, having one operation which transfer amount from one account to another account, and also it initializes the account which create the instance by 10,000 in value. So, first we execute the gateway, the operation to transfer the amount, you will see the transaction happening on the blockchain and at the same time the amount is getting reduced from the sender's account and getting added to the receiver. So this concludes this session of aetherium. Learning aetherium by example, where we looked at how to create the virtual machine how, you know, went through the code and then executed that. And you will notice that here, the environment the virtual machine gave you everything out of the box, you don't need to worry about setting up the test, test net test RPC. net, you don't need to worry about having truffle install, you don't need to worry about the code.

So this is a very quick way to learn about aetherium by example and once you are done with all the testing, do make sure that you go and stop your virtual machine. Okay, so you need to select your virtual machine and click on stop. Otherwise the VM will be attending and you'll get charged for it.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.