For Educational Purpose only
git clone https://github.com/hitesharma/jsChain.git
cd jsChain
const EC = require("elliptic").ec;
const ec = new EC("secp256k1");
const myKeyPair = ec.genKeyPair();The myKeyPair object contains the public & private key:
console.log("Public key:", myKeyPair.getPublic("hex"));
console.log("Private key:", myKeyPair.getPrivate("hex"));const { Blockchain } = require("./src/blockchain");
const { Transaction } = require("./src/transaction");
const myChain = new Blockchain();// Transfer 10 coins from my wallet address to `toAddress`
const tx = new Transaction(myKeyPair.getPublic("hex"), "toAddress", 10);
tx.signTransaction(myKeyPair);
myChain.addTransaction(tx);myChain.minePendingTransactions(myKeyPair.getPublic("hex"));console.log('Wallet's balance: ', myChain.getBalance(myKeyPair));console.log(`Latest block's Hash: ${myChain.getLatestBlock()});console.log("Verify Chain: ", myChain.verifyChain() ? "Yes" : "No");