MCPcopy
hub / github.com/Savjee/SavjeeCoin

github.com/Savjee/SavjeeCoin @main sqlite

repository ↗ · DeepWiki ↗
25 symbols 67 edges 9 files 15 documented · 60%
README

Project logo

SavjeeCoin

.github/workflows/ci.yml 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.sign(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

Core symbols most depended-on inside this repo

createSignedTx
called by 23
tests/helpers.js
addTransaction
called by 20
src/blockchain.js
minePendingTransactions
called by 12
src/blockchain.js
getBalanceOfAddress
called by 10
src/blockchain.js
calculateHash
called by 8
src/blockchain.js
isValid
called by 7
src/blockchain.js
createBlockchainWithTx
called by 7
tests/helpers.js
sign
called by 6
src/blockchain.js

Shape

Method 16
Class 6
Function 3

Languages

TypeScript100%

Modules by API surface

src/blockchain.js22 symbols
tests/helpers.js3 symbols

Dependencies from manifests, versioned

coveralls3.0.6 · 1×
debug4.1.1 · 1×
elliptic6.5.4 · 1×
eslint8.8.0 · 1×
eslint-config-standard17.0.0-0 · 1×
eslint-plugin-import2.18.2 · 1×
eslint-plugin-node11.0.0 · 1×
eslint-plugin-promise6.0.0 · 1×
eslint-plugin-standard5.0.0 · 1×
mocha10.0.0 · 1×
nyc15.1.0 · 1×
prettier2.7.1 · 1×

For agents

$ claude mcp add SavjeeCoin \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact