Blockchain in Swift

Main Functions and Variables for Accounts

Your browser needs to be JavaScript capable to view this video

Try reloading this page, or reviewing your browser settings

In this video segment, you will get information about main functions and variables of our project.

Keywords

  • Main Class for Blockchain
  • Blockchain accounts
  • Bitcoin Chain
  • Blocks

About this video

Author(s)
Elshad Karimov
First online
29 September 2019
DOI
https://doi.org/10.1007/978-1-4842-5382-3_6
Online ISBN
978-1-4842-5382-3
Publisher
Apress
Copyright information
© Elshad Karimov 2019

Video Transcript

Main functions and variables for accounts. Here, I will do the log main back-end functions and declare the variables that we need for our application. Let’s continue to do go deep.

Let’s switch to our V controller class. You’ll see that all our outlets are connected. We need to do these 200 transactions and print them to console. Before declaring our functions and variables, we should explode bitcoin blockchain a little bit.

Bitcoins come from oral account. Let’s say this account will be 000. When you mine a bitcoin, it means that you solve math problems, and a certain amount of bitcoins are issued as a reward. This provides a smart way to use the currency, and also creates an incentive for people to mine.

In our app, let’s make the reward 150 bitcoins. And to do so, we need to declare variables in our application. Let’s continue to do so.

Our variable will be first account, which is 1010. And then second account, which is 1011. Then we will define bitcoin chain. It will be type of blockchain. And reward– and reward– it will be 150.

And we need a master account from where all the bitcoins come from. This is our main account with numbers 000. It has 10 million bitcoins. You can think of this account like a bank, where for every word, 150 bitcoins are taken out or fed into the rightful account.

This will be for accounts. Kind of dictionary. It’s a cool tool. First will be account number. And then second will be number of bitcoins in it. And in our case, it is 10 million.

We also define an alert which will be shown every time a transaction could not be completed. Let invalid– invalid– alert equal to UI, alert controller.

Title will be invalid transaction. Message will be, please check the details– details– of your transaction. And preferred style will be alert.

Apart from these variables, I need also main functions which will help me to handle the transaction to record to the console and to check the validity of the block chain. I will write each of these functions in our next videos.