today im going to show you how to create w wallet and check its #ethereum balance using #Unity3d ! in the next video we will make our first eth transaction using Ropsten testnet to send eth between dummy accounts in Unity!
Send me a gwei! (ether address, all donations accepted!) 0x95F4EaB8A738F4F27e7c04aEe1E10C8E666C2D0c send me a satoshi! (bitcoin address, all donations accepted!) 31zvj8ybxVVTLw6nPvAHYqu3qDVhC1sRqk
Want to send me something? Technivorous 902 n Hughes Blunt Sd 57522
Heyo, we are back with another Ethereum for Unity tutorial.
This is going to be the demo 2, and we are going to go ahead and grab this script.
Now on the last one, I put the link for the script you needed down below.
This one is exactly the same script, but with a couple of updates.
We are actually going to grab the whole thing here.
The start all the way down to here,
and we're going to take that and pop it into our pre-made class.
But I did make a new account called account F.
Okay, so we're going to be using this instead.
And in doing so, we can actually take our F test,
and we can run a little comparison to see what the difference is.
So if we scroll back up here, we can see that this is basically the same thing.
So I'm saying get account balance here,
and then it's starting our code routine and doing this.
This is a lot more commenting here.
So, oh no, you know what?
That is the wrong file altogether.
We need to delete that.
This is the one we're looking at.
There we go.
Okay, so that's a lot closer.
So basically, we're doing the same thing,
except we don't have that public string wallet here.
So let's throw that in, public string wallet.
Okay, and then we are going to...
Wait, we need that above start.
Let's go ahead and close this now.
And then we're going to put wallet here.
Okay, and then basically below this code routine
is going to be another code routine we're going to call create account.
We're using strong password.
That's not actually a strong password.
That is a joke.
But yeah, it works.
So basically, it's going to encrypt it using this string here.
You won't be able to decrypt it without it.
So make sure whatever you put in for a password, you remember.
And in fact, let's again go and create a couple of public strings.
Public string strong password.
This will allow us to enter whatever we want for a password
and we'll get different encryption stuff.
We don't have the using methods in here.
We need to bring those.
The reason I didn't grab the whole thing is because I'm not...
This isn't the name of my class.
I changed it to account F because account's kind of a common name for...
Let's grab all of these using statements.
Go back here.
And this is what we were missing, the JSON RPC methods.
So now that that's gone, we're going to change public string strong password.
This to use our variable instead of just that random phrase.
All right.
And then this is our callback method for get account balance.
We saw that in the last video.
This is our new code.
Okay.
So this is basically what we've added.
Create account.
It's going to take the string, the password that we use,
and it is going to create a callback.
Basically, it's going to use the netherium signer to generate a key.
And then it is going to use that EC key to get a public address and a private key as bytes.
Then it's going to create a key store.
And it's going to save this data in that key store.
And then the encrypted JSON is going to be where it does exactly that.
Encrypt and generate default key store using password, private key, address.
Basically, all the information that we put in there.
So let's go ahead.
Save this.
I need to pop back over to Unity here.
And we're actually going to delete this guy here that says F net.
Because we don't need that.
We're actually going to delete the get balance script and the F test script as well.
Does take a minute to update everything.
Delete.
Yes.
Can't undo.
I know.
Okay.
So here we have our script that we were just working on.
This whole working script other than the variables we changed is available at the link below.
But basically, I've created an empty called account.
And we are going to drag and drop it there.
Which should give us access to our inspector variables.
So here we go.
So technically, since I don't have a wallet yet, I don't have anything to put in here.
So I'm not going to fill that out just yet.
The strong password we're going to make.
All right.
Just a bunch of random stuff.
So now we should get an error saying that there's no such wallet here.
But it should still create the account that we need and return some stuff there in the console.
So let's check it out.
Turn my phone down here so it stops dinging.
I love group messages.
All right.
So get balance request did fail.
Couldn't get the balance because we didn't enter a wallet.
However, we did get a wallet here.
This is the wallet we created.
And we got a return text here for our cipher in order to...
This is basically our account access here.
So in the return, let's take a look in detail and see what information we're getting there.
Basically, we are printing the address and then we are printing the encrypted JSON.
So the encrypted JSON is the stuff that gets passed in here.
So the password, the private key, and the address are all included in that JSON.
It's encrypted.
The only thing that's not encrypted is the wallet itself.
So you can see basically everything we need in order to access the wallet
and store those variables and save everything.
So all of this here is the return off of that.
So now you know how to create an account.
You know how to access the variables in that account.
Let's go ahead and let's take...
Since we're getting a return here, let's take this guy.
Go ahead and delete that.
And down here in create account, when we create account,
we're going to make it so it automatically returns the account balance as well in here.
And you can see it is using...
We're going to change this address.
All right, so now we're using this variable that we're getting back.
And we're checking the balance there.
So let's see if this works properly or if it's already encrypted at that point.
Shouldn't get any errors this time because we're not calling that method on an empty wallet item.
We're calling it on the returned wallet from this object here.
So I know this seems like a lot to take in.
I'm showing you how to set this up step by step
because when we get to the step for sending and receiving,
you're going to want to be able to see these signing tags and things like that
and make sure that you know what actually is going on.
You do need a signing key in order to send something from your wallet.
And that is included in the objects that we have here.
So get balance request failed.
Balance request failed.
So I guess the question is, did it use this address?
Or did it use an obfuscated one in here?
So let's see.
I'm going to undo what I did.
So we don't really need that there.
And I do want this method to work properly for getting the balance.
Let's see if we can get...
I can't steal that from there.
So let's go ahead because I want to run this error free.
Let's go ahead and run it without using any balance retrieval at all.
Just the callback for setting up the new account.
So save that.
Run again.
Take a second to compile here.
It shouldn't take too long.
And we'll run it again.
We should just get these two lines.
This actually already has a coroutine for getting the balance in here.
Moving this doesn't do me any good.
It does the exact same thing after we're done creating an account.
So now that it's loaded, it's saying get balance request failed.
It's still not finding a balance.
Oh, you know what?
Okay, I think I may know where the problem is coming in here.
Okay, so we are not using CoVan.
So let's go get the right address here.
Ropsten.
Copy.
This is a test network.
This should work better.
Okay, if we can get it to compile again.
I really should edit out some of this compiling time.
But honestly, I like hanging out with you guys.
So you know, you're just gonna have to suffer through seeing my ugly mug up here.
How do you like that?
And let's see where this error is at.
Count of 64.
Balance request failed.
Error receiving data failed.
Okay, well, let's make sure that our network's still working this way.
Let's go and grab dummy account wallet like we did in the other one.
And uncommented that.
And it should at least give us the balance of our actual account,
if not the balance of the new account we're creating.
So we're making sure basically that we haven't broken our connection to the network here.
So let's see what we got here.
Did I not save that?
Try it again.
Yeah, I would edit through some of this stuff.
But honestly, I have done this before.
And there are a couple steps you have to take.
Okay, so we're getting...
All right, now everything's working.
We're getting zero returns for...
That is the wallet that it's calling the first time.
This is the one that it's calling from our second line.
So it is now working.
So let's check out this here.
It's at seven a minute ago, and now it's at nine.
You can see it did just make a couple requests.
So make sure that we got our...
Yep, F, get balance, and then F block number.
Let's see if we can jump this up to nine just to ensure that our code is working properly.
So it should call this twice.
Once on the wallet that we punched in, and once on the wallet that it's making.
Both of the values should be zero again.
But we should also get to see a change here.
It's already made one of those requests.
And it's got to create the wallet in order to make...
Oh, yep, there we go.
And still busy, which means it's still communicating.
And here we have it.
Yep, it's made two requests, and there it is.
So you can see it working in real time.
And we have created a wallet.
We have checked the balance of that wallet, as well as checking the balance of a regular wallet.
So the next step is to add something to that wallet.
In order to do that, we have to have something to add.
So we're going to be using our test account to send some to a wallet that we just made.
And that will be our first actual transaction sending Ethereum with Unity.
So stay tuned.
That will be in the next video.
I apologize this video got a little bit long with all of the waiting.
But I'd like to go through everything step by step and let you see where there are snags,
and where you might have trouble in order to properly diagnose any problems you might have.
Because if I just give you the steps, when you do run into problems,
you're not going to know how to solve it.
Basically, a lot of waiting for reloading while we made a few minor adjustments.
But that's going to be it for this video, guys.
Don't forget to hit the subscribe button and leave a like.
And TechNiverse out.