SwiftChain is a simple implementation of a blockchain, written purely in Swift.
The goal if SwiftChain is to provide a strong foundation layer for any and all interesting applications of blockchain that you might want to build.
In order to correctly compile SwiftChain (in Xcode):
- You must be using a workspace.
- Drag the
SwiftChain.xcodeproj
to your workspace - Drag the
CryptoSwift.xcodeproj
to your workspace - Go to your target's settings, hit the "+" under the "Embedded Binaries" section, and select
SwiftChain.framework
@import SwiftChain
To work with SwiftChain
, first import SwiftChain
into the relevant files where you'd like to use it.
Then, create a new blockchain by calling the Blockchain()
constructor. Optionally, you may provide data that should be included in the genesis block of your blockchain. See the documentation for details.
Once you have a Blockchain
object, you can use:
let blockchain = Blockchain()
let myData = "some data object".data(using: .utf8)!
blockchain.addBlock(with: myData)
This will:
- Begin hashing the provided data using the algorithm the blockchain is supporting. This call is blocking, and can potentially take a long time.
- Append that data into a new block.
- Extend your blockchain object by one block.
Feel free to open an issue to request a feature you'd like to see!
- Please note the difference between installing a compiled framework from CocoaPods or Carthage, and copying the source code
- Search issues
- Ask in the issues section
- Search issues
- Ask in the issues section
SwiftChain depends on CryptoSwift.
CryptoSwift is a collection of cryptographic algoriths and tools implemented in Swift. CryptoSwift is essential to keep SwiftChain accessible to as many platforms as possible, by not depending on pre-compiled system crypto tools.
If you have ideas or like what you see here and want to support the project, you could:
- Let people know this library exists (๐ spread the word ๐)
- Contribute code, issues and pull requests
If you have questions or are having problems, you should:
- Make sure you are using the latest version of the library. Check the release-section.
- Search or ask questions on stackoverflow with the
SwiftChain
tag - Search known issues for your problem (open and closed)
- Create new issues (please search known issues beforehand and avoid creating duplicate issues)
I have written Xcode quick-help documentation for the library. Since this library is generally the key building blocks for a project, having it close to the source is the best approach. Please refer to Apple's Documentation for writing quick help documentation.
SwiftChain is available under the MIT license. See the LICENSE file for more information.