Blockchain CLI
A Rust library provides a command-line interface (CLI) for interacting with blockchain.
Reference implementation
Features
new(address, difficulty, reward): Initialize a new blockchain with the specified parameters.get_transactions(): Get a list of current transactions in the blockchain.get_transaction(hash): Get a transaction by its hash.add_transaction(from, to, amount): Add a new transaction to the blockchain.get_last_hash(): Get the hash of the last block in the blockchain.update_difficulty(difficulty): Update the mining difficulty of the blockchain.update_reward(reward): Update the block reward.generate_new_block(): Generate a new block and append it to the blockchain.get_merkle(transactions): Calculate the Merkle root hash for a list of transactions.proof_of_work(header): Perform the proof-of-work process to mine a block.hash(item): Calculate the SHA-256 hash of a serializable item.
Options
| Option | Description |
|---|---|
address |
The address associated with the blockchain. |
difficulty |
The initial mining difficulty level of the network. |
reward |
The initial block reward for miners. |
Safety
This crate uses #![forbid(unsafe_code)] to ensure everything is implemented in 100% safe Rust.
Usage
Run the following Cargo command in your project directory::
extern crate blockchain;
use Chain;
Contributing
- Build an application:
- Test an application:
- Run an application:
- Run clippy:
Run lint:
- Generate documentation in HTML format: