From the course: Blockchain Programming in iOS Using Swift

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Generating keys for blocks

Generating keys for blocks

- Now that we have all our models set up correctly, it's time to generate the key which will be used to generate the hash. Okay, and if you remember from our earlier lectures, the key is basically the transactions, plus the hash of the previous one, plus the nonce, and plus the index. and plus the index. and plus the index. We can also add the index to it, which represents the position of the block inside the blockchain. So let's go ahead and create a key. We're going to start with creating a key property which only has a getter. So what can we actually return? So return, string, self, dot, index so we can convert the index to a string. That is not a big deal. We can convert it, the previous hash in the string, which is already a string. And we can also convert the nons to a string using the string function. Or what about the transactions? I mean I can't simply say something like this because it won't really make any sense. Transactions is a list of transaction object. Let's actually…

Contents