Giter VIP home page Giter VIP logo

savjeecoin's Introduction

Project logo

SavjeeCoin

Build Status Coverage Status GitHub Issues GitHub Pull Requests License


โš ๏ธ For education purposes only. This is by no means a complete implementation and it is by no means secure!

Features

  • Simple proof-of-work algorithm
  • Verify blockchain (to prevent tampering)
  • Generate wallet (private/public key)
  • Sign transactions

๐Ÿ Getting Started

Install library

npm install --save savjeecoin

Generate a keypair

To make transactions on this blockchain you need a keypair. The public key becomes your wallet address and the private key is used to sign transactions.

const EC = require('elliptic').ec;
const ec = new EC('secp256k1');

const myKey = ec.genKeyPair();

The myKey object now contains your public & private key:

console.log('Public key:', myKey.getPublic('hex'));
console.log('Private key:', myKey.getPrivate('hex'));

Create a blockchain instance

Now you can create a new instance of a Blockchain:

const {Blockchain, Transaction} = require('savjeecoin');

const myChain = new Blockchain();

Adding transactions

// Transfer 100 coins from my wallet to "toAddress"
const tx = new Transaction(myKey.getPublic('hex'), 'toAddress', 100);
tx.signTransaction(myKey);

myChain.addTransaction(tx);

To finalize this transaction, we have to mine a new block. We give this method our wallet address because we will receive a mining reward:

myChain.minePendingTransactions(myKey.getPublic('hex'));

๐Ÿ“ฝ Video tutorial

This source code comes from my video series on YouTube. You can check them here:

Video 1: Simple implementation Video 2: Adding Proof-of-work
Video 3: Mining rewards & transactions Video 4: Signing transactions
Video 5: Building a front-end in Angular

savjeecoin's People

Contributors

savjee avatar hasezoey avatar thedevminertv avatar nowshad-sust avatar thebox193 avatar masnwilliams avatar salah-saleh avatar hamidineayoub avatar

Watchers

James Cloos 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.