Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# Simple Node.js Blockchain

This project implements a simple blockchain using Node.js. It includes a blockchain client that can send transactions, mine blocks, and retrieve block data. It mines block on an average of 3 seconds.
It also include a module for issuing assets on stellar testnet

## Getting Started

1. Clone the repository:
   ```bash
   git clone https://github.com/guudc/simple-blockchain.git
   cd simple-blockchain
  1. Install dependencies:

    npm install
  2. Start the blockchain client:

    npm start

Usage

Blockchain Client

Initialize a New Blockchain Client

const BlockchainClient = require("./src/controller/blockchain");

// Initialize a new blockchain client with a custom client ID
const client = new BlockchainClient(123);

Sending a Transaction

// Send a transaction
const transaction = {
  timestamp: Date.now(),
  data: "Date goes here"
};

client.sendTransaction(transaction);

Mining Blocks

// Start mining
client.mine();

// Stop mining
client.mine(false);

Getter Functions

// Get the current block number
const blockNumber = client.getBlockNumber();

// Retrieve data of a specific block
const blockData = client.getBlockAt(blockNumber);

// Retrieve data of all blocks
const allBlocks = client.getAllBlocks();

Stellar Assets

const { start } = require("./src/controller/stellar_asset")

// Issue a new asset
start("AssetName")

License

This project is licensed under the GNU General Public License - see the LICENSE file for details.


About

This project is a straightforward implementation of a blockchain using Nodejs

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages