2.3.1 • Published 5 years ago

@mytsu/blockchain v2.3.1

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

@mytsu/blockchain

Stars Forks NPM Version

Basic implementation of a blockchain. Made up with typescript while following @SavjeeTutorials video.

As said by the original author, this is made for educational purpuses only. The project is made in Typescript to allow better readabillity.

Install

npm i @mytsu/blockchain

Usage

import { Blockchain, Transaction } from './block';
import { ec } from 'elliptic';

const EC = new ec('secp256k1');

const myKey: ec.KeyPair = EC.keyFromPrivate(<ec.KeyPair><unknown>'your private key goes here');
const myWallet: string = myKey.getPublic('hex');

let coin = new Blockchain();

const tx1 = new Transaction(myWallet, 'destination wallet goes here', 10);

tx1.signTransaction(myKey);
coin.addTransaction(tx1);

console.log('\nStarting miner');
coin.minePendingTransactions(myWallet);

console.log('\nBalance of my account is: ', coin.getBalanceOfAddress(myWallet));

console.log('\nIs chain valid?', coin.isChainValid());

Notes

You might notice the <ec.KeyPair><unknown> on the private key, it's elliptic typings weird settings.

2.3.1

5 years ago

2.3.0

5 years ago

2.2.0

5 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.0.0

5 years ago