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.

Mining a block

Mining a block

- [Instructor] In the last lecture, you learned that how you can return a blockchain in JSON format from our Web API implemented in Vapor. But let's see how we can actually mine a new block. For mining a new block, I'm gonna start with our routes. Right now we have a route for hello, which is kind of useless, you can delete that. And we have a route for a blockchain, which returns, well, the blockchain. But we don't really have any route where we can post a new transaction. So let's go ahead and create that route. Whoops. Router.post in this case because we will be posting a route. And this time, what we're gonna do is we're going to post a route, hold on a second, whoops, router.post and we're gonna post a particular route which will post to a server which will match on map to a certain class. So which class is gonna map to, whatever we are sending the key value pair? Well, the transaction class, because that is what we are sending. So all the key value pairs in JSON that we will be…

Contents