-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalyze-known-mints.ts
More file actions
119 lines (107 loc) · 4.27 KB
/
analyze-known-mints.ts
File metadata and controls
119 lines (107 loc) · 4.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import { formatUnits } from 'viem'
import { createPublicClient, http } from 'viem'
import { beraChain } from '../src/config.js'
const RPC_URL = process.env.ANALYZE_RPC || 'https://rpc.berachain.com'
// Hard-coded list of transactions that interacted with both Steady Teddys + MiTeddy contracts
const MINT_TX_HASHES = [
'0xf1eb6a8a29cf12c83707b1389bef4fe1b43047db72cbdc56d9de1fd605fa7f43',
'0x0bc33c92c0f2e44515d805cdbb76b6a41ed10e50781984654268f6b6d2e0ed34',
'0x9db39e29ef80cbad9f6c3a50454ec75f3440f021d95aca5ef2c4e9155a0f156c',
'0x35cb3dfaae978952a9ff668bcc90ab01cbd551cd096c4340132355c4be2ee42c',
'0x61b49b712b1241c4de98cd9b8ce9c369d414cffbf56a11f699af85beaefe7cef',
'0xa40a842c1741e3dd1bc40c7ebcc2f1e81d63c8e60fdc97aded850f78b3d0c439',
'0x4186f342678518f6d294000d82ee029971bb5d0524b705bd2f1672d32b4166d4',
'0x083284bfa15001408c785ff6e9b9d746575e51b23390e87a54a00e0f5ef48002',
'0x2af30bf7b190c68f3a37d84862cbe4bba019a19408f0b66b477241e61e06bb42',
'0x8378298296f30061d799466a522300691a281869e2d5a72dbcf514c6154fc23d',
'0x83fecff98ee9c2aac8a7c735d3d97c52fa018fce224bb0aeee2c4e22a5bba036',
'0xaa6fe9088b2ff3b9aff18ba4936e85c045299638770af2fa734da9d617d2fe31',
'0x03d31dbcd5a51372c3b4e57df036fa2791f6f9d1976b5aa717b39035b62ca03d',
'0xcc55a4b9cd86f9cd2846e74df503144f36144a4df3925e68f593c2f41fcbcf74',
'0x56400f9e27eff08ffe1642611db00534216c65834680bdef4a1e9d4cad0032d1',
'0xa9511c8fe37d160f6327608bc4b64807b2ccd4d7c497ea51dbc5ddc295a9ea49',
] as const
type MintInsight = {
txHash: string
status: 'success' | 'failed'
blockNumber: number
timestampUtc: string
timestampPst: string
transactionIndex: number
from: string
gasLimit: string
gasUsed: string
effectiveGasPriceGwei: number
maxFeePerGasGwei: number | null
maxPriorityFeePerGasGwei: number | null
valueEth: string
}
const formatPst = (tsMs: number) =>
new Intl.DateTimeFormat('en-US', {
timeZone: 'America/Los_Angeles',
hour12: false,
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
}).format(tsMs)
async function main(): Promise<void> {
const client = createPublicClient({
chain: beraChain,
transport: http(RPC_URL, { timeout: 15_000 }),
})
const insights: MintInsight[] = []
for (const hash of MINT_TX_HASHES) {
try {
const [tx, receipt] = await Promise.all([
client.getTransaction({ hash }),
client.getTransactionReceipt({ hash }),
])
const block = await client.getBlock({ blockNumber: receipt.blockNumber })
const timestampMs = Number(block.timestamp) * 1000
const status = receipt.status === 'success' ? 'success' : 'failed'
insights.push({
txHash: hash,
status,
blockNumber: Number(receipt.blockNumber),
timestampUtc: new Date(timestampMs).toISOString(),
timestampPst: formatPst(timestampMs),
transactionIndex: receipt.transactionIndex,
from: tx.from,
gasLimit: tx.gas.toString(),
gasUsed: receipt.gasUsed.toString(),
effectiveGasPriceGwei: Number(receipt.effectiveGasPrice) / 1e9,
maxFeePerGasGwei: tx.maxFeePerGas ? Number(tx.maxFeePerGas) / 1e9 : null,
maxPriorityFeePerGasGwei: tx.maxPriorityFeePerGas ? Number(tx.maxPriorityFeePerGas) / 1e9 : null,
valueEth: formatUnits(tx.value, 18),
})
} catch (error) {
console.error(`Failed to analyze ${hash}: ${(error as Error).message}`)
}
}
insights.sort((a, b) => a.blockNumber - b.blockNumber)
console.table(
insights.map((mint) => ({
block: mint.blockNumber,
pstTime: mint.timestampPst,
status: mint.status,
gasUsed: mint.gasUsed,
effTipGwei: mint.effectiveGasPriceGwei.toFixed(2),
maxFeeGwei: mint.maxFeePerGasGwei?.toFixed(2) ?? 'n/a',
priorityGwei: mint.maxPriorityFeePerGasGwei?.toFixed(2) ?? 'n/a',
nonceIdx: mint.transactionIndex,
from: mint.from.slice(0, 10) + '…',
hash: mint.txHash.slice(0, 10) + '…',
})),
)
await import('fs').then(({ writeFileSync }) =>
writeFileSync('mint-insights.json', JSON.stringify(insights, null, 2)),
)
console.log(`\nSaved detailed data to mint-insights.json (RPC: ${RPC_URL})`)
}
main().catch((error) => {
console.error('mint analysis failed:', error)
process.exit(1)
})