Fetch EVM Logs
Self-contained skill for fetching EVM event logs only: scaffold → ask user for ABI → configure → run s1/s2.
init-project.sh → user provides ABI → edit contract.ts → pnpm s1 → pnpm s2
Bundled templates live in this skill's templates/ directory (no external repo required).
Out of scope: aggregation, claim stats, CSV metrics, or pnpm s3. For those, use the separate evm-log-stats skill.
Step 0 — Initialize project
When the user asks to fetch logs and no project exists yet, scaffold first:
bash ~/.cursor/skills/fetch-evm-logs/scripts/init-project.sh [target_dir]
Default target: ./fetch_evm_logs. Creates full Node.js + TypeScript project, runs pnpm install.
Agent workflow:
- Ask or infer target directory (default
fetch_evm_logsin workspace). - Run
init-project.shfrom the skill directory. - Proceed to configuration below.
Do not ask the user to clone a repo — this skill ships the template.
Step 1 — Obtain contract ABI from user
Mandatory. Before writing src/abi/ or editing contract.ts, explicitly ask the user to provide the contract ABI.
Ask clearly, for example:
请提供目标合约的 ABI(完整合约 ABI JSON,或至少包含目标 event 的 fragment)。可从 Etherscan「Contract → Code → Contract ABI」复制,或直接粘贴 JSON。
Do not:
- Use the bundled placeholder ABI as the real ABI
- Guess or fabricate an ABI from the event name alone
- Fetch ABI from a block explorer unless the user explicitly asks you to
Wait for the user to supply ABI (paste in chat, or point to a local file). Collect contract address and chainId first (Step 2), then write ABI to:
src/abi/abi_{address}_{chainId}.json
Example: src/abi/abi_0x4ccdb547cdfd4d3b929d4556ddf9f5ed9d861aad_41443.json
addressis lowercase- No manual import in
contract.ts— ABI is loaded automatically from this path
Acceptable formats:
- Full contract ABI JSON array
- Minimal event fragment array containing the target event
If the user also provides eventName, use it; otherwise infer the event name from the ABI and confirm with the user before running s1.
Step 2 — Gather other contract info
Ask or infer the remaining fields (can be collected together with Step 1):
| Item | Example |
|---|---|
| Contract address | 0x4CcDb... |
| RPC URL | https://... |
| Block range | startBlock, endBlock or latest |
| Event name | AirdropClaimed (must exist in user-provided ABI) |
| Token decimals | 18 (optional) |
| chainId | 41443 |
Step 3 — Configure
ABI file: src/abi/abi_{address}_{chainId}.json
Write the user-provided ABI using the naming rule above. contract.ts loads it by address + chainId — no import statement needed.
src/contract.ts
export const Distributors = {
contracts: {
MyContract: {
address: '0x...',
startBlock: 735573,
endBlock: 'latest',
rpc: 'https://...',
chainId: 41443,
eventName: 'AirdropClaimed', // must match ABI event name
tokenDecimals: 18,
},
},
};
parseLogand topic hash are auto-built from ABI (utils/parse.log.ts).- Parsed
datakeys match ABI param names (account,root,amount, …).
Step 4 — Run
cd <target_dir>
pnpm s1 # pull → output/{address}_{chainId}/logs.txt
pnpm s2 # parse → output/{address}_{chainId}/logs.json
pnpm typecheck
Stop after s2. Do not run pnpm s3 or edit stats.config.ts under this skill.
Project layout (after scaffold)
fetch_evm_logs/
├── package.json # s1, s2 scripts (s3 may exist in template; ignore here)
├── tsconfig.json
├── src/
│ ├── contract.ts # ← customize
│ ├── abi/abi_{address}_{chainId}.json # ← user-provided ABI
│ ├── s1.pull.contract.logs.ts
│ ├── s2.prase.logs.ts
│ └── utils/
└── output/
└── {address}_{chainId}/
├── logs.txt
└── logs.json
Do not edit s1, s2, utils/parse.log.ts, utils/utils.pull.log.ts unless switching to block-explorer API.
Parsed log shape
{ txHash: string; blockNumber: number; data: Record<string, string | boolean> }
Checklist
- [ ] init-project.sh completed
- [ ] User provided ABI (not placeholder)
- [ ] ABI written to src/abi/abi_{address}_{chainId}.json
- [ ] contract.ts configured
- [ ] pnpm s1 → verify log count
- [ ] pnpm s2 → spot-check data.* fields
Pitfalls
- Wrong
eventName→ zero logs - RPC range too large → reduce
pageSizein s1 (default 1000) - Wrong
tokenDecimals→ amount scale errors - ABI filename must match
abi_{address}_{chainId}.json(lowercase address) - Downstream field names must use ABI names (
account, notaddress)
Additional Resources
- Scaffold script: scripts/init-project.sh
- File layout: reference.md
- AirdropClaimed example: examples.md
