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.
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 [email protected]
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.
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
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.
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
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
- Fork the main branch
- Create your feature branch:
git checkout -b my-new-feature
- Add your changes:
git add .
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request
ankanbag101 - Making the blog post and repository that served as inspiration and much of the code for this repository
We use SemVer for versioning. For the versions available, see the tags on this repository.
- 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.
MIT License © Andrea SonnY