Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shu223/blockchainswift
A simple Blockchain with Swift
https://github.com/shu223/blockchainswift
Last synced: 4 days ago
JSON representation
A simple Blockchain with Swift
- Host: GitHub
- URL: https://github.com/shu223/blockchainswift
- Owner: shu223
- License: mit
- Created: 2018-01-09T09:19:02.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-05-04T00:44:31.000Z (8 months ago)
- Last Synced: 2024-12-23T04:07:30.637Z (11 days ago)
- Language: Swift
- Homepage:
- Size: 174 KB
- Stars: 362
- Watchers: 13
- Forks: 25
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# BlockchainSwift
A simple Blockchain with Swift.
[![License](http://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat
)](http://mit-license.org)
[![Twitter](https://img.shields.io/badge/[email protected]?style=flat)](http://twitter.com/shu223)## What is this?
This is an implementation of Blockchain with Swift based on **this great article**:
[Learn Blockchains by Building One – Hacker Noon](https://hackernoon.com/learn-blockchains-by-building-one-117428612f46)
## How to build
- Open `BlockchainSwift.xcodeproj` with Xcode
- Build and Run!![](blockchainsample.gif)
## What is interesting?
Just seeing the sample app is NOT fun at all. Trying to implement by yourself according to the reference articles would be fun :)
The implementation is quite simple, **less than 200 lines**.
For example, Here is the `Block`:
```swift:Block.swift
struct Block: Codable {
let index: Int
let timestamp: Double
let transactions: [Transaction]
let proof: Int
let previousHash: Data// Hashes a Block
func hash() -> Data {
let encoder = JSONEncoder()
let data = try! encoder.encode(self)
return data.sha256()
}
}
```Here are the articles:
- [Learn Blockchains by Building One – Hacker Noon](https://hackernoon.com/learn-blockchains-by-building-one-117428612f46)
日本語版(Python):
- [ブロックチェーンを作ることで学ぶ 〜ブロックチェーンがどのように動いているのか学ぶ最速の方法は作ってみることだ〜](https://qiita.com/hidehiro98/items/841ece65d896aeaa8a2a)
日本語版(Swift):
- [Swiftでブロックチェーンを実装してみる](https://qiita.com/shu223/items/ebe59325f36fbf25e3d6)
*The "Consensus" part is available in the [feature/consensus](https://github.com/shu223/BlockchainSwift/tree/feature/consensus) branch.