Skip to content
Proyectos

shu223/BlockchainSwift

Ver en GitHub

Acerca de

Una cadena de bloques sencilla implementada en Swift.

Negocios y finanzas

Cómo se miden estas cifras

Crecimiento de estrellas medido

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Recopilando historial

Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.

README.md

Original

BlockchainSwift

A simple Blockchain with Swift.

License Twitter

What is this?

This is an implementation of Blockchain with Swift based on this great article:

Learn Blockchains by Building One – Hacker Noon

How to build

  • Open BlockchainSwift.xcodeproj with Xcode
  • Build and Run!

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:

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:

日本語版(Python):

日本語版(Swift):

*The "Consensus" part is available in the feature/consensus branch.

Explorar proyectos relacionados

Cargando…