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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
//! Mint-level security — the Solana honeypot analog. On EVM you have to
//! simulate a sell; on Solana the rug levers are readable directly off the
//! mint account: an active mint authority (infinite supply), an active freeze
//! authority (your tokens can be frozen mid-trade — the classic Solana
//! honeypot), and the Token-2022 extensions (transfer fees = sell tax,
//! permanent delegate = confiscation, transfer hooks = programmable blocks,
//! non-transferable / default-frozen = outright honeypots).
use crate::chain::{MetaplexMeta, MintInfo};
use crate::config;
use crate::types::{Flag, Severity};
use serde_json::{json, Value};
pub struct MintAnalysis {
pub flags: Vec<Flag>,
pub section: Value,
pub name: Option<String>,
pub symbol: Option<String>,
}
fn ext<'a>(mint: &'a MintInfo, name: &str) -> Option<&'a Value> {
mint.extensions
.iter()
.find(|e| e.get("extension").and_then(|x| x.as_str()) == Some(name))
}
pub fn analyze(mint: &MintInfo, meta: Option<&MetaplexMeta>) -> MintAnalysis {
let mut flags = vec![];
let is_2022 = mint.program == config::TOKEN_2022;
// An extension the RPC node's build cannot decode arrives as
// `{"extension": "unparseableExtension"}`. Every check below is a lookup by
// extension NAME, so an undecodable one is indistinguishable from an absent
// one — and `pausableConfig` is recent enough that older public nodes do
// exactly this. Left silent, a live pause authority publishes as a clean
// mint with "you can always sell". Unknown powers are not absent powers.
let undecodable = mint
.extensions
.iter()
.filter(|e| {
e.get("extension")
.and_then(|x| x.as_str())
.is_some_and(|n| n == "unparseableExtension" || n == "unknownExtension")
})
.count();
if undecodable > 0 {
flags.push(Flag::new(
"extension_undecodable",
Severity::Warning,
"Token-2022 extension could not be decoded",
format!(
"This mint carries {undecodable} Token-2022 extension(s) that the RPC could not decode, so Solwatch cannot tell what they do. Undecoded extensions may include transfer hooks, pause authority, or fee configs — the honeypot levers this tool normally checks. Do NOT read the absence of those flags as their absence on-chain; re-run against an up-to-date RPC (SOLWATCH_RPC_URL)."
),
10,
));
}
// --- Authorities (both token programs) ---
match &mint.mint_authority {
Some(a) => flags.push(Flag::new(
"mint_authority",
Severity::Danger,
"Mint authority still active",
format!(
"The wallet {} can create unlimited new tokens at any time, diluting every holder to zero. Safe tokens revoke this.",
short(a)
),
30,
)),
None => flags.push(Flag::new(
"mint_authority",
Severity::Good,
"Mint authority revoked",
"No one can ever create more of this token — the supply is fixed.".into(),
0,
)),
}
match &mint.freeze_authority {
Some(a) => flags.push(
Flag::new(
"freeze_authority",
Severity::Danger,
"Freeze authority active — sell-block risk",
format!(
"The wallet {} can FREEZE any holder's tokens, instantly blocking them from selling. This is the #1 Solana honeypot lever.",
short(a)
),
25,
)
.hard(),
),
None => flags.push(Flag::new(
"freeze_authority",
Severity::Good,
"Freeze authority revoked",
"No one can freeze your tokens — you can always sell.".into(),
0,
)),
}
// --- Token-2022 extensions ---
let mut ext_summary = vec![];
if is_2022 {
if ext(mint, "nonTransferable").is_some() {
ext_summary.push("nonTransferable");
flags.push(
Flag::new(
"non_transferable",
Severity::Critical,
"🍯 Token is NON-TRANSFERABLE",
"The mint is flagged non-transferable — you can receive it but never send or sell it. This is a honeypot by construction.".into(),
60,
)
.hard(),
);
}
if let Some(e) = ext(mint, "defaultAccountState") {
let state = e
.pointer("/state/accountState")
.and_then(|s| s.as_str())
.unwrap_or("");
if state == "frozen" {
ext_summary.push("defaultAccountState=frozen");
flags.push(
Flag::new(
"default_frozen",
Severity::Critical,
"🍯 New accounts start FROZEN",
"Every buyer's token account is frozen by default — you cannot sell unless the team manually unfreezes you. Honeypot mechanics.".into(),
60,
)
.hard(),
);
}
}
// Flag on an ACTIVE delegate, not on the extension's presence. The
// extension stays on the mint after the delegate is revoked, and the
// field then serializes as JSON null — the old `unwrap_or("?")` fired a
// 60-weight honeypot hard-fail naming the delegate as "?" on a token
// whose dev had done the right thing and revoked it.
if let Some(e) = ext(mint, "permanentDelegate") {
let d = e
.pointer("/state/delegate")
.and_then(|s| s.as_str())
.filter(|s| !s.is_empty() && *s != config::SYSTEM_PROGRAM);
if let Some(d) = d {
ext_summary.push("permanentDelegate");
flags.push(
Flag::new(
"permanent_delegate",
Severity::Critical,
"🍯 Permanent delegate can seize tokens",
format!(
"The address {} is a permanent delegate — it can transfer or burn tokens OUT of any holder's wallet without permission.",
short(d)
),
60,
)
.hard(),
);
}
}
if let Some(e) = ext(mint, "transferHook") {
let prog = e.pointer("/state/programId").and_then(|s| s.as_str());
// Some nodes serialize a revoked hook as the default pubkey rather
// than null — that is "no hook", not a hook at address 111…111.
if let Some(p) = prog.filter(|p| !p.is_empty() && *p != config::SYSTEM_PROGRAM) {
ext_summary.push("transferHook");
flags.push(Flag::new(
"transfer_hook",
Severity::Danger,
"Transfer hook — programmable transfer control",
format!(
"Every transfer calls custom program {} which can reject sells for any reason (allowlists, trading hours, honeypot switches). Trust requires reading that program.",
short(p)
),
20,
));
}
}
if let Some(e) = ext(mint, "transferFeeConfig") {
// Token-2022 carries TWO fee configs because a fee change is
// epoch-SCHEDULED: `newerTransferFee` only takes effect at its
// stated epoch, and until then the fee actually charged is
// `olderTransferFee`. Unconditionally preferring "newer" let a dev
// set 50% active now and schedule 0% for a future epoch — we read 0
// bps and published an 8-point advisory on a 50% sell tax.
//
// Reading the current epoch would cost an extra RPC round-trip, so
// we take the MAX of the two: fail toward warning, never toward a
// false all-clear. A scheduled REDUCTION is then reported at the
// higher rate, which is the safe direction to be wrong in.
let newer = e
.pointer("/state/newerTransferFee/transferFeeBasisPoints")
.and_then(|b| b.as_u64());
let older = e
.pointer("/state/olderTransferFee/transferFeeBasisPoints")
.and_then(|b| b.as_u64());
let bps = newer.unwrap_or(0).max(older.unwrap_or(0));
let scheduled_change = matches!((newer, older), (Some(n), Some(o)) if n != o);
let pct = bps as f64 / 100.0;
if bps > 0 {
ext_summary.push("transferFee");
}
if pct >= 25.0 {
flags.push(
Flag::new(
"transfer_fee",
Severity::Critical,
"🍯 Confiscatory transfer tax",
format!("A {pct}% fee is skimmed from EVERY transfer — selling costs you {pct}% off the top. Effectively a honeypot."),
40,
)
.hard(),
);
} else if pct >= 10.0 {
flags.push(Flag::new(
"transfer_fee",
Severity::Danger,
"High transfer tax",
format!("A {pct}% fee is taken from every transfer (buys AND sells)."),
20,
));
} else if bps > 0 {
flags.push(Flag::new(
"transfer_fee",
Severity::Warning,
"Transfer tax",
format!("A {pct}% fee is taken from every transfer."),
8,
));
}
if scheduled_change {
flags.push(Flag::new(
"transfer_fee_scheduled",
Severity::Warning,
"Transfer fee is scheduled to change",
format!("This mint has two transfer-fee configs — a fee change is scheduled at an epoch boundary. Solwatch reports the HIGHER of the two ({pct}%) so a scheduled increase is never missed; verify which is currently active before trading."),
5,
));
}
// A 0% fee today is only safe if the fee AUTHORITY is also revoked —
// otherwise the controller can raise the tax to as much as 100% at
// any time. A revoked authority serializes as JSON null (→ None).
if bps == 0 {
if let Some(a) = e
.pointer("/state/transferFeeConfigAuthority")
.and_then(|s| s.as_str())
.filter(|s| !s.is_empty())
{
flags.push(Flag::new(
"transfer_fee_authority",
Severity::Warning,
"Transfer fee can be switched on",
format!(
"The fee is 0% today, but {} still controls it and can raise the transfer tax — up to 100% — at any time. Safe tokens revoke the fee authority.",
short(a)
),
8,
));
}
}
}
// Same presence-vs-active distinction as permanentDelegate: the
// extension survives revocation, so only an actual authority counts.
if let Some(a) = ext(mint, "mintCloseAuthority")
.and_then(|e| e.pointer("/state/closeAuthority").and_then(|s| s.as_str()))
.filter(|s| !s.is_empty() && *s != config::SYSTEM_PROGRAM)
{
ext_summary.push("mintCloseAuthority");
flags.push(Flag::new(
"mint_close_authority",
Severity::Warning,
"Mint can be closed",
format!("A close authority ({}) exists on the mint — an unusual power for a community token.", short(a)),
5,
));
}
// Pausable (Token-2022): a pause authority can halt EVERY transfer of the
// token at once — a global freeze equivalent to freeze authority, and a
// honeypot lever. Currently-paused = active honeypot; a live authority =
// the lever exists. Missing/None authority = the power is revoked.
if let Some(e) = ext(mint, "pausableConfig") {
let paused = e
.pointer("/state/paused")
.and_then(|b| b.as_bool())
.unwrap_or(false);
let authority = e
.pointer("/state/authority")
.and_then(|s| s.as_str())
.filter(|s| !s.is_empty());
if paused {
ext_summary.push("paused");
flags.push(
Flag::new(
"paused",
Severity::Critical,
"🍯 All transfers are PAUSED",
"Every transfer of this token is currently paused — nobody can sell until the team unpauses. Honeypot mechanics.".into(),
60,
)
.hard(),
);
} else if let Some(a) = authority {
ext_summary.push("pausable");
flags.push(
Flag::new(
"pausable",
Severity::Danger,
"Transfers can be paused",
format!(
"The wallet {} can pause ALL transfers at any moment — a global freeze that blocks every holder from selling. Equivalent to a freeze authority.",
short(a)
),
25,
)
.hard(),
);
}
}
}
// --- Metadata (Metaplex for classic SPL; tokenMetadata extension for 2022) ---
let (mut name, mut symbol, mut mutable, mut update_auth) = (None, None, None, None);
if let Some(m) = meta {
name = Some(m.name.clone()).filter(|s| !s.is_empty());
symbol = Some(m.symbol.clone()).filter(|s| !s.is_empty());
mutable = Some(m.is_mutable);
update_auth = Some(m.update_authority.clone());
} else if let Some(e) = ext(mint, "tokenMetadata") {
name = e
.pointer("/state/name")
.and_then(|s| s.as_str())
.map(String::from);
symbol = e
.pointer("/state/symbol")
.and_then(|s| s.as_str())
.map(String::from);
update_auth = e
.pointer("/state/updateAuthority")
.and_then(|s| s.as_str())
.map(String::from);
mutable = update_auth.as_ref().map(|_| true);
}
if mutable == Some(true) {
flags.push(Flag::new(
"mutable_metadata",
Severity::Info,
"Metadata can still be changed",
"The team can rename the token or swap its image/links at any time.".into(),
2,
));
}
let section = json!({
"tokenProgram": mint.program,
"isToken2022": is_2022,
"decimals": mint.decimals,
"supply": mint.supply_raw,
"mintAuthority": mint.mint_authority,
"freezeAuthority": mint.freeze_authority,
"extensions": ext_summary,
"metadata": {
"name": name,
"symbol": symbol,
"isMutable": mutable,
"updateAuthority": update_auth,
},
});
MintAnalysis {
flags,
section,
name,
symbol,
}
}
fn short(a: &str) -> String {
if a.len() < 12 {
a.to_string()
} else {
format!("{}…{}", &a[..4], &a[a.len() - 4..])
}
}