Giter VIP home page Giter VIP logo

simple-blockchain-network's Introduction

simple-blockchain-network

This repository shows a simple blockchain network implementation. Each instance can be considered a blockchain node. You can use the API endpoints defined in routes.js to interact with the nodes.

Launch a node

Launch a node by running node index.js --port <PORT> (defaults to port 3000)

Example

  1. Launch two nodes:

node index.jes --port 3000

node index.jes --port 3001

  1. Register node: curl -X POST http://localhost:3000/register --data '{"address":"http://localhost:3001"}'

  2. Verify node is registered by retrieving the nodes endpoint: curl http://localhost:3000/nodes and curl http://localhost:3001/nodes should both show the other node as registered.

  3. Add a transaction: curl -X POST http://localhost:3000/transaction --data '{"from":"hank","to":"walter","qty":7}'

  4. Add another transaction: curl -X POST http://localhost:3000/transaction --data '{"from":"saul","to":"gus","qty":3}'

  5. Verify the transactions are added to the transaction pool on both nodes: curl http://localhost:3001/transactions and curl http://localhost:3001/transactions should both show the same unprocessed transactions.

  6. Ask either one of the nodes to mine a new block: curl -X POST http://localhost:3000/mine or curl -X POST http://localhost:3001/mine

  7. Verify the transaction is added to the chain: curl http://localhost:3000/chain and curl http://localhost:3001/chain

simple-blockchain-network's People

Contributors

mcrapts avatar dependabot[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.