A simple Node.js/TypeScript project that connects to the MegaETH testnet Blockscout API and computes interesting blockchain statistics, printing results to the console.
- Block Statistics: Transaction volume, average transactions per block, block time analysis
- Gas Price Analysis: Average, min, and max gas prices in gwei
- Address Activity: Unique addresses, senders, and receivers
- Contract Deployments: Count and percentage of contract creation transactions
- Top Addresses: Most active addresses by transaction count
- Transaction Values: Total, average, min, and max ETH transferred
- Node.js (v18 or higher)
- npm
- Clone the repository and navigate to the project directory:
cd megaeth-tn-stats- Install dependencies:
npm installnpm startOr using ts-node directly:
npx ts-node src/index.tsBy default, the application analyzes the last 100 blocks. You can change this by setting the BLOCK_RANGE environment variable:
BLOCK_RANGE=50 npm startnpm testRun tests in watch mode:
npm run test:watchCompile TypeScript to JavaScript:
npm run buildThe compiled files will be in the dist/ directory.
megaeth-tn-stats/
├── src/
│ ├── index.ts # Main entry point
│ ├── api-client.ts # Blockscout API client wrapper
│ └── statistics.ts # Statistics computation logic
├── tests/
│ ├── api-client.test.ts
│ └── statistics.test.ts
├── package.json
├── tsconfig.json
└── README.md
The project uses the Blockscout API for MegaETH testnet:
- Base URL:
https://megaeth-testnet.blockscout.com/api
The application includes:
- Retry logic with exponential backoff for transient failures
- Rate limit detection and user-friendly error messages
- Network error handling
MIT