@xdc.org/interaction-detector 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +33 -31
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -51,7 +51,7 @@ Combines: **events** + **direct calls** + **internal calls** + **transaction tra
51
51
  ## Installation
52
52
 
53
53
  ```bash
54
- npm install xdc-interaction-detector
54
+ npm install @xdc.org/interaction-detector
55
55
  ```
56
56
 
57
57
  **Dependencies:** `ethers` v6, `axios`, `ws` — all installed automatically.
@@ -61,7 +61,7 @@ npm install xdc-interaction-detector
61
61
  ## Quick Start
62
62
 
63
63
  ```typescript
64
- import { ContractWatcher } from 'xdc-interaction-detector';
64
+ import { ContractWatcher } from '@xdc.org/interaction-detector';
65
65
 
66
66
  const watcher = new ContractWatcher({
67
67
  // RPC endpoints
@@ -80,8 +80,9 @@ const watcher = new ContractWatcher({
80
80
 
81
81
  // Explorer API — enables direct & internal call detection
82
82
  explorer: {
83
- apiUrl: 'https://xdc.blocksscan.io/api',
84
- apiKey: 'YOUR_API_KEY', // optional — higher rate limits
83
+ apiUrl: 'https://api.etherscan.io/v2/api',
84
+ apiKey: 'YOUR_ETHERSCAN_API_KEY', // optional — higher rate limits
85
+ chainId: 50, // XDC Mainnet
85
86
  rateLimitPerSec: 5,
86
87
  },
87
88
 
@@ -120,7 +121,7 @@ Watches one or more contract addresses for all interactions in real-time using t
120
121
  **Creating a watcher:**
121
122
 
122
123
  ```typescript
123
- import { ContractWatcher } from 'xdc-interaction-detector';
124
+ import { ContractWatcher } from '@xdc.org/interaction-detector';
124
125
 
125
126
  const watcher = new ContractWatcher({
126
127
  // ─── Required ───────────────────────────────────────────
@@ -141,9 +142,9 @@ const watcher = new ContractWatcher({
141
142
 
142
143
  // ─── Optional: Explorer API (direct + internal calls) ───
143
144
  explorer: {
144
- apiUrl: 'https://xdc.blocksscan.io/api',
145
- apiKey: 'YOUR_XDCSCAN_API_KEY', // optional — get higher rate limits
146
- chainId: 50, // required for Etherscan v2
145
+ apiUrl: 'https://api.etherscan.io/v2/api', // Etherscan v2 supports XDC
146
+ apiKey: 'YOUR_ETHERSCAN_API_KEY', // optional — get higher rate limits
147
+ chainId: 50, // XDC Mainnet (required for Etherscan v2)
147
148
  rateLimitPerSec: 5, // default: 5 req/s
148
149
  pollIntervalMs: 60_000, // how often to check explorer (default: 60s)
149
150
  },
@@ -254,7 +255,7 @@ Scans a block range for all events and interactions involving a contract. Automa
254
255
  **Scanning for events:**
255
256
 
256
257
  ```typescript
257
- import { BlockScanner } from 'xdc-interaction-detector';
258
+ import { BlockScanner } from '@xdc.org/interaction-detector';
258
259
 
259
260
  const scanner = new BlockScanner({
260
261
  rpcUrl: 'https://rpc.xinfin.network',
@@ -264,8 +265,9 @@ const scanner = new BlockScanner({
264
265
 
265
266
  // Optional: explorer for direct + internal tx enrichment
266
267
  explorer: {
267
- apiUrl: 'https://xdc.blocksscan.io/api',
268
- apiKey: 'YOUR_API_KEY',
268
+ apiUrl: 'https://api.etherscan.io/v2/api',
269
+ apiKey: 'YOUR_ETHERSCAN_API_KEY',
270
+ chainId: 50,
269
271
  },
270
272
  });
271
273
 
@@ -324,7 +326,7 @@ Traces a single transaction to extract the full execution story: call tree, stat
324
326
  **Full trace:**
325
327
 
326
328
  ```typescript
327
- import { TransactionTracer } from 'xdc-interaction-detector';
329
+ import { TransactionTracer } from '@xdc.org/interaction-detector';
328
330
 
329
331
  const tracer = new TransactionTracer({
330
332
  rpcUrl: 'https://archive-rpc.xinfin.network', // must support debug_traceTransaction
@@ -398,7 +400,7 @@ const { stateDiffs, balanceChanges } = await tracer.traceStateDiffs('0xTxHash');
398
400
  **Call tree utilities:**
399
401
 
400
402
  ```typescript
401
- import { flattenCallTree, findCallsTo, extractInvolvedContracts } from 'xdc-interaction-detector';
403
+ import { flattenCallTree, findCallsTo, extractInvolvedContracts } from '@xdc.org/interaction-detector';
402
404
 
403
405
  // Flatten the nested tree into a linear array
404
406
  const allCalls = flattenCallTree(result.callTree);
@@ -418,14 +420,14 @@ const addresses = extractInvolvedContracts(result.callTree);
418
420
  Standalone Etherscan-compatible API client. Works with XDCScan, Etherscan v2, BSCScan, PolygonScan, and any Etherscan-compatible explorer.
419
421
 
420
422
  ```typescript
421
- import { ExplorerClient } from 'xdc-interaction-detector';
423
+ import { ExplorerClient } from '@xdc.org/interaction-detector';
422
424
 
423
425
  const explorer = new ExplorerClient({
424
- apiUrl: 'https://xdc.blocksscan.io/api', // XDCScan
425
- // apiUrl: 'https://api.etherscan.io/v2/api', // Etherscan v2 (80+ chains)
426
- // apiUrl: 'https://api.bscscan.com/api', // BSCScan
427
- apiKey: 'YOUR_API_KEY', // optional — higher rate limits
428
- chainId: 50, // required for Etherscan v2
426
+ apiUrl: 'https://api.etherscan.io/v2/api', // Etherscan v2 — supports XDC + 80 chains
427
+ // apiUrl: 'https://xdc.blocksscan.io/api', // XDCScan (alternative)
428
+ // apiUrl: 'https://api.bscscan.com/api', // BSCScan
429
+ apiKey: 'YOUR_ETHERSCAN_API_KEY', // optional — higher rate limits
430
+ chainId: 50, // XDC Mainnet (required for Etherscan v2)
429
431
  rateLimitPerSec: 5, // built-in token-bucket rate limiter
430
432
  });
431
433
  ```
@@ -480,13 +482,13 @@ explorer.destroy(); // Cleans up rate limiter timers
480
482
 
481
483
  **Explorer compatibility:**
482
484
 
483
- | Explorer | Base URL | Chain | Free Rate Limit |
484
- | ---------------- | --------------------------------- | ------------------------ | --------------- |
485
- | **XDCScan** | `https://xdc.blocksscan.io/api` | XDC Mainnet (50) | 5 req/s |
486
- | **Etherscan v2** | `https://api.etherscan.io/v2/api` | 80+ chains via `chainId` | 5 req/s |
487
- | **BSCScan** | `https://api.bscscan.com/api` | BSC (56) | 5 req/s |
488
- | **PolygonScan** | `https://api.polygonscan.com/api` | Polygon (137) | 5 req/s |
489
- | **Custom** | Any Etherscan-compatible URL | Any EVM chain | Configurable |
485
+ | Explorer | Base URL | Chain | Free Rate Limit |
486
+ | -------------------- | --------------------------------- | --------------------------------- | --------------- |
487
+ | **Etherscan v2**| `https://api.etherscan.io/v2/api` | XDC (50) + 80 chains via chainId | 5 req/s |
488
+ | **XDCScan** | `https://xdc.blocksscan.io/api` | XDC Mainnet (50) | 5 req/s |
489
+ | **BSCScan** | `https://api.bscscan.com/api` | BSC (56) | 5 req/s |
490
+ | **PolygonScan** | `https://api.polygonscan.com/api` | Polygon (137) | 5 req/s |
491
+ | **Custom** | Any Etherscan-compatible URL | Any EVM chain | Configurable |
490
492
 
491
493
  ---
492
494
 
@@ -495,7 +497,7 @@ explorer.destroy(); // Cleans up rate limiter timers
495
497
  The decoder handles both standard Solidity ABI encoding and XDC's non-standard encoding (where all params are packed into the `data` field).
496
498
 
497
499
  ```typescript
498
- import { AbiRegistry, EventDecoder } from 'xdc-interaction-detector';
500
+ import { AbiRegistry, EventDecoder } from '@xdc.org/interaction-detector';
499
501
 
500
502
  // ── Register ABIs ────────────────────────────────────────────
501
503
  const registry = new AbiRegistry();
@@ -514,7 +516,7 @@ registry.register(
514
516
  registry.register('0xAnotherContract', require('./MyContract.json').abi, 'MyContract');
515
517
 
516
518
  // Auto-fetch from block explorer (verified contracts only)
517
- const explorer = new ExplorerClient({ apiUrl: 'https://xdc.blocksscan.io/api' });
519
+ const explorer = new ExplorerClient({ apiUrl: 'https://api.etherscan.io/v2/api', chainId: 50 });
518
520
  const success = await registry.registerFromExplorer('0xVerifiedContract', explorer, 'VerifiedToken');
519
521
  console.log(success ? 'ABI fetched!' : 'Contract not verified');
520
522
 
@@ -543,7 +545,7 @@ if (decoded) {
543
545
  Checkpoints let the watcher resume from where it left off after a restart.
544
546
 
545
547
  ```typescript
546
- import { MemoryCheckpoint, FileCheckpoint, createCheckpointBackend } from 'xdc-interaction-detector';
548
+ import { MemoryCheckpoint, FileCheckpoint, createCheckpointBackend } from '@xdc.org/interaction-detector';
547
549
 
548
550
  // ── Memory (development / testing) ───────────────────────────
549
551
  const memCp = new MemoryCheckpoint();
@@ -595,7 +597,7 @@ import {
595
597
 
596
598
  // Logger
597
599
  Logger, // new Logger('MyModule', 'info')
598
- } from 'xdc-interaction-detector';
600
+ } from '@xdc.org/interaction-detector';
599
601
  ```
600
602
 
601
603
  ---
@@ -680,7 +682,7 @@ import {
680
682
 
681
683
  ```
682
684
  ┌──────────────────────────────────────────────────────────┐
683
- xdc-interaction-detector
685
+ @xdc.org/interaction-detector
684
686
  │ │
685
687
  │ ┌───────────────────────────────────────────────────┐ │
686
688
  │ │ ContractWatcher (real-time monitoring) │ │
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xdc.org/interaction-detector",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Standalone TypeScript library for detecting all on-chain contract interactions — events, direct calls, internal calls, and transaction tracing — on XDC and EVM-compatible chains.",
5
5
  "author": "XinFinOrg",
6
6
  "license": "MIT",