#add-on #blockchain #decentralization #bitcoin

app rust-blockchain

A simple blockchain implementation for add-ons in applications

1 unstable release

0.1.0 Mar 14, 2021

#33 in #decentralization

Custom license

13KB
258 lines

Rust-Blockchain

Blockchain Cryptocurrency model Implemented in Rust.

To get started

git clone https://github.com/j0fiN/rust-blockchain
cd rust-blockchain
cargo run

Your terminal should output this after execution.

[
    Block {
        prevhash: "",
        transaction: Transaction {
            amount: 100.0,
            payer: PublicKey([212, 228, 66, 151, 84, 100, 15, 69, 176, 15, 174, 89, 213, 77, 1, 197, 165, 14, 211, 66, 26, 195, 82, 173, 80, 62, 245, 2, 238, 119, 27, 111]),    
            payee: PublicKey([212, 228, 66, 151, 84, 100, 15, 69, 176, 15, 174, 89, 213, 77, 1, 197, 165, 14, 211, 66, 26, 195, 82, 173, 80, 62, 245, 2, 238, 119, 27, 111]),    
        },
        ts: 2021-03-12T23:27:21.159007300+05:30,
    },
    Block {
        prevhash: "2c127d95f718dacab98f43ae1d7c3d723c0255f4eba111b2dd56930f87651169",
        transaction: Transaction {
            amount: 1200.0,
            payer: PublicKey([0, 108, 242, 50, 94, 62, 119, 120, 34, 42, 236, 105, 155, 216, 125, 152, 45, 178, 243, 105, 244, 173, 234, 85, 227, 221, 1, 118, 171, 197, 22, 10]),
            payee: PublicKey([161, 164, 235, 77, 164, 93, 133, 27, 245, 112, 95, 17, 221, 74, 219, 99, 1, 129, 8, 231, 243, 159, 80, 130, 170, 206, 165, 194, 110, 75, 217, 105]),
        },
        ts: 2021-03-12T23:27:21.161052100+05:30,
    },
]

To develop it as an add-on to your application

Code(main.rs) Doc
chain::Chain::new() Builds the blockchain with genesis block append by default.
wallet::Wallet::new() builds the node with digital signature components.
satoshi.create_transaction(1200., notildore.pub_key) Builds the transaction object and signs it and returns back trnsaction, signature and nonce.
notildore.verify_and_add(transaction, satoshi.pub_key, sig, nonce, true, &mut blockchain) transaction verification is done along with block append

Testing

cargo test

Future updates

Conclusion

Do contribute is you want to make it better or ⭐ the repo if you like it!

Dependencies

~6.5–9MB
~103K SLoC