A Node.js script to analyze Solana transaction fees and compute units. This script fetches blocks from the Solana blockchain, calculates priority fees, and generates reports in either a SQLite3 database or a CSV file.
- Fetch Blocks: Retrieve blocks from the Solana blockchain.
- Priority Fee Analysis: Calculate max, average, median, and 95th percentile fees.
- Compute Unit Analysis: Calculate max, average, and median compute units.
- Storage Options: Save results to a SQLite3 database or a CSV file.
- Customizable: Control the number of blocks, batch size, and delay between fetches.
-
Clone the repository:
git clone https://github.com/your-username/solana-fee-report.git cd solana-fee-report
-
Install dependencies:
npm install
Run the script with the following command:
node solana-fee-report.js -n <numSamples> -s <storage> -b <batchSize> -d <delay>
Argument | Description | Default Value |
---|---|---|
-n, --numSamples |
Number of block batches to analyze (e.g., -n 1000 ). |
Required |
-s, --storage |
Storage format: db for SQLite3 database or csv for CSV file. |
db |
-b, --batchSize |
Number of blocks per batch (1 to 100). | 10 |
-d, --delay |
Delay in seconds between block fetches. | 2 |
-h, --help |
Show help message and exit. | N/A |
-
Analyze 100 batches of 20 blocks and save to a CSV file with a 5-second delay:
node solana-fee-report.js -n 100 -s csv -b 20 -d 5
-
Analyze 50 batches of 10 blocks and save to a SQLite3 database with the default 2-second delay:
node solana-fee-report.js -n 50 -s db
-
Analyze 1000 batches of 5 blocks and save to a CSV file with no delay:
node solana-fee-report.js -n 1000 -s csv -b 5 -d 0
If the -s db
option is used, the script will create a SQLite3 database file named solana_data.db
with the following schema:
CREATE TABLE block_data (
id INTEGER PRIMARY KEY AUTOINCREMENT,
start_slot INTEGER,
end_slot INTEGER,
total_transactions INTEGER,
average_tps REAL,
max_fee_sol REAL,
average_fee_sol REAL,
median_fee_sol REAL,
percentile95_fee_sol REAL,
max_cu INTEGER,
average_cu REAL,
median_cu INTEGER,
sol_price_usd REAL
);
If the -s csv
option is used, the script will create a CSV file named solana_data.csv
with the following columns:
start_slot,end_slot,total_transactions,average_tps,max_fee_sol,average_fee_sol,median_fee_sol,percentile95_fee_sol,max_cu,average_cu,median_cu,sol_price_usd
@solana/web3.js
: Solana JavaScript API.axios
: HTTP client for fetching Solana price data.sqlite3
: SQLite3 database operations.minimist
: Command-line argument parsing.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request.
If you find this project useful, consider giving it a ⭐️ on GitHub!