prevent-mint-front-running
Use when an NFT drop is scarce and bots may snipe allowlist spots or token ids. Applies on-chain allowlisting, private submission, and id randomization to blunt front-running.
- License 许可
- MIT
- 最近更新
- 2026-11-12
- Stars
- ★ 81
- Forks
- 17
01 前言 Front Matter
- name
- prevent-mint-front-running
- description
- Use when an NFT drop is scarce and bots may snipe allowlist spots or token ids. Applies on-chain allowlisting, private submission, and id randomization to blunt front-running.
02 资源文件 3
- 许可证LICENSE1.0 KB
- 参考文档SOURCE.md352 B
- 参考文档TRUST.auto.yaml2.1 KB
03 SKILL.md 正文
Prevent mint front-running
Bots watch the mempool and buy scarce mints the moment a transaction is visible, sniping allowlist spots and rare token ids before a human's transaction lands.
Procedure
-
Identify what a bot can predict: an open
mint()with no allowlist, and token ids assigned bytotalSupply(). If the id is knowable, bots can target a specific rare id. -
Enforce the allowlist on-chain with a Merkle root or signature so a bot that is not listed cannot mint even after seeing the transaction:
cast call $NFT "merkleRoot()(bytes32)" --rpc-url $RPC -
Submit through a private or protected endpoint so the transaction is not visible before inclusion:
cast send $NFT "mint(uint256)" 1 --private-key $KEY --rpc-url $PROTECT_RPC -
Randomize token id assignment after mint time via a committed reveal (see commit-reveal), making id sniping pointless.
-
Consider
require(tx.origin == msg.sender)only with eyes open — it blocks naive bot contracts but not a bot that owns an EOA. -
Set a per-transaction and per-wallet cap so one bot cannot take an entire phase:
grep -nE 'maxMintPerTx|maxPerWallet|require\(.*minted' src/*.sol -
Add a commit-delay:
commit()thenrevealMint()two blocks later, so mempool sniping gains nothing. -
Race-test on a fork:
forge test --match-test testSniping --fork-url $RPC -vvvv
Pitfalls
- A public RPC rebroadcasts your transaction to the general mempool, defeating a private submission.
- Bots also watch the pending set and simulate;
tx.originchecks do not stop EOAs. - Reveal-after-mint removes id sniping but not supply sniping — keep the per-wallet cap too.
- A gas price set lower than the bots' guarantees your transaction is delayed, not protected.
- Accepting deposits before the allowlist check lets a bot's transaction reserve slots it later abandons.
Verification
forge test --match-test testSniping --fork-url $RPC -vvvv
Pass: a bot contract minting with a forged or absent proof reverts and the per-wallet cap holds under concurrent calls. Report the protection used (allowlist / private mempool / reveal) and the cap.
04 同仓库更多 Skills
recipe-performance
Diagnose a specific MetaMask user flow's real-app performance and Sentry critical-user-flow telemetry with deterministic mm-harness recipes. Use for CUF boundaries, cold/warm/background-resume behavior, latency regressions, lifecycle tags, duplicate or blocking network requests, long tasks, layout/paint cost, screen redraws, React rerenders, or browser trace analysis where tests alone cannot prove the real app.
mexc-spot-websocket
MEXC Spot WebSocket workflows for public streams, protobuf handling, depth maintenance, listen keys, and private streams without exposing API keys.
mexc-spot-rest
MEXC Spot REST workflows for public data, signed account requests, orders, wallet/admin actions, and secure signing without exposing API keys.
mexc-futures-websocket
MEXC Futures WebSocket workflows for public streams, private account/order/position streams, ping/pong, subscriptions, and depth maintenance.
0xklen-version-and-refresh-sanctions-lists
暂无简介
verify-tests-cover-changed-lines
Use when a PR adds code that the existing suite may not exercise. Measures patch coverage — the share of newly changed lines hit by tests — before approving.