This is my submission for the summer of bitcoin challenge 2021, built using NodeJS (JavaScript).
Summer of Bitcoin 2021 - Challenge - Task 1
Problem Statement - The miners (crypto) would like to include the transactions in a block that maximize their total fees. Therefore develope a program to output the transaction id's, separated by newlines, which make a valid block, maximizing the fee to the miner. Transactions MUST appear in order i.e. no transaction should appear before one of its parent teansaction, if any.
Keynote 1: The best way to achieve maximum fees with minimized weight would be by applying Knapsack algorithm for implementating a Greedy based technique.
Keynote 2: The transactions are sorted on the basis of the ratio of fee/weight
.
Keynote 3: If there are two transactions having the same fee/weight
ratio, we can then sort them on the basis of the number of their required parent transactions.
These instructions will get you a copy of the project up and running on your local machine for testing, evaluation and contribution purposes.
The only prerequisites for this project is NodeJS and NPM (Node Package Manager). Hence, before starting please make sure that Node.js (v12.16.0 or above) and NPM (v6.13.4 or above) are installed in your machine. If not installed already, follow the instructions below:
# Check if Node.js and NPM is already installed
$ node -v
$ npm -v
If respective version numbers are displayed, then they are already installed and you are good to go. Otherwise head over to Node.js Download Page and NPM Download instructions and download the latest version. Then, to check if installed successfully, follow the above mentioned step.
Fork this repository and then clone that to your local machine. Follow the steps given below to run the project locally:
Step 1. Installing dependencies:
Run npm install
in the project folder from your terminal to install all project dependencies.
Step 2. Running code:
Run node index.js
- It will generate a new block.txt
file in the Result
folder containing the processed transactions.
On successful execution of the above listed steps, the following output is obtained:
SUCCESS Block created and stored successfully in result folder
Result: In the procesed Block (./result/block.txt)
Total number of transactions processed: 3,217
Total weight processed: 3,999,784
Total fees collected by the miner: 5,817,973 (satoshis)