1.3.0 • Published 2 years ago

crypto-framework v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

npm version npm downloads GitHub top language GitHub all releases NPM node-current GitHub commit activity GitHub contributors Maintenance

Crypto Framework

Welcome to the repository for the NodeJS package crypto-framework! This package is meant to be used for a building block to your own cryptocurrency.

FOREWARNING

If v1.2.0 or v1.3.0 cause issues, you can download the latest 100% stable version, v1.1.1, like so:

npm i --save crypto-framework@1.1.1

v1.2.0 Added new custom error types, and the places where I added my new ValidationError may cause it to break. This works at runtime, but in production may misbehave due to how TypeScript handles errors. Please read the JSDoc comments if you dare to use this version. v1.3.0 will hopefully fix this issue.

Update v1.3.0: I've stabilised the error handling a bit more. This works at runtime. However, I have no way to check this in production, all I know is that any validation methods that returned false in v1.1.1 are back to returning false as well as returning a ValidationError after so the project can run as intended. If you have any issues, you can submit an issue or pull request in the repository.

Prerequisites

This project requires NodeJS (version 10.24.1 or later) and npm. Node and npm are really easy to install. To make sure you have them available on your machine, try running the following command.

$ npm -v && node -v
6.14.12
v10.24.1

Table of contents

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Installation

BEFORE YOU INSTALL: please read the prerequisites

Start with cloning this repo on your local machine:

$ git clone https://github.com/Archigan1/Crypto-Framework.git
$ cd Crypto-Framework

To install and set up the library, run:

$ npm i --save crypto-framework
$ yarn add crypto-framework
$ pnpm add crypto-framework

API

Check our (future!) documentation page for API usage.

NOTE: The API does, in fact, exist, but we don't have any official documentation page yet. I'll sum it up here, with the classes and their methods (hover over the methods in your code for a description):

// Block class
Block(data: Array<Transaction>, previousHash: string | null);
Block.mine(difficulty: number);
Block.hasValidTransactions(chain: Chain): boolean;

// Chain class
Chain(chain: Array<Block>, difficulty: number);
static Chain.create(firstUserAddress: string): Chain;
Chain.addBlock(transactions: Array<Transaction>);
Chain.isValid(): boolean;
Chain.addTransaction(transaction: Transaction);

// Transaction class
Transaction(senderPubKey: string, receiverPubKey: string, amount: number);
Transaction.sign(wallet: Wallet);
Transaction.isValid(chain: Chain): string | number | boolean;

// Wallet class
Wallet();
Wallet.send(amount: number, receiver: string, blockchain: Chain);

//Error classes (new as of v1.2.0)
throw new BlockError(message: string);

throw new ValidationError(object: string); // READ JSDOC PROMPTS FOR ERRORS

Contributing

  1. Fork the main branch
  2. Create your feature branch: git checkout -b my-new-feature
  3. Add your changes: git add .
  4. Commit your changes: git commit -am 'Add some feature'
  5. Push to the branch: git push origin my-new-feature
  6. Submit a pull request

Credits

ankanbag101 - Making the blog post and repository that served as inspiration and much of the code for this repository

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Archigan1 - Most of the programming behind this package - Archigan1
  • CookieGamer733 - Helped to debug and write some of the files. Also assisted with JSDoc. - CookieGamer733
  • Terrain2 - Helped to debug without touching the files - Terrain2

See also the list of contributors who participated in this project.

License

MIT License © Andrea SonnY

1.2.0

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.3.0

2 years ago

1.2.1

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago