मुख्य सामग्री पर जाएं
प्रत्येक Virtual Environment 0xc100000000000000000000000000000000000000 पर एक precompile contract उजागर करता है। एक transaction के अंदर से इस precompile पर functions को call करने से आपके contracts on-chain state को सीधे manipulate कर सकते हैं, storage slots, ETH balances, ERC-20 token balances, nonces, और event logs, बिना accounts को impersonate किए या helper proxies deploy किए। ये cheatcodes Admin RPC methods के पूरक हैं। Admin RPC methods transaction के बाहर से state को manipulate करते हैं (JSON-RPC के माध्यम से)। precompile transaction के अंदर से state को manipulate करता है (Solidity call के माध्यम से)। precompile का उपयोग तब करें जब आपके setup को atomic रहने, tx hash से replayable होने, या कई slots पर एक loop में चलने की आवश्यकता हो।

Interface

इस file को अपने project में IVnetPrecompile.sol के रूप में जोड़ें:
IVnetPrecompile.sol
अपने contract में fixed address पर इसे reference करें:

Functions

Storage

Balance

ERC-20 balances

precompile token के balance storage slot को स्वचालित रूप से locate करता है, इसलिए किसी slot input की आवश्यकता नहीं है। मानक mapping layouts सीधे resolve होते हैं और पहले holder के बाद cache किए जाते हैं; गैर-मानक layouts token के balanceOf execution को probe करके खोजे जाते हैं।
जो tokens balance storage slot में अतिरिक्त flags pack करते हैं, वे balanceOf को उसी के अनुसार report करते हैं। उदाहरण के लिए, USDC slot के top bit को reserve करता है, इसलिए setMaxErc20Balance के बाद उसका balanceOf 2^255 - 1 लौटाता है।

Nonce

Events

emitEvent एक log fire करता है जिसका address field target है, न कि calling contract। Downstream consumers (indexers, subgraphs, webhooks) log को target से real emission के रूप में मानते हैं। नौ overloads एक वैकल्पिक unindexed data payload के साथ शून्य से चार indexed topics कवर करते हैं: topic1 आमतौर पर keccak256("EventName(type,type,...)") होता है। उदाहरण, एक USDC Transfer spoof करें:

Cheatcode events

प्रत्येक state-changing cheatcode precompile address (0xc100000000000000000000000000000000000000) से एक संबंधित event उत्सर्जित करता है: emitEvent के माध्यम से spoof किए गए log के लिए receipt का निरीक्षण करते समय, precompile की अपनी entries को अनदेखा करने के लिए logs[] को target address द्वारा filter करें।

ज्ञात सीमाएँ

  • Base-आधारित Virtual Environments। Base पर Solidity cheatcodes उपलब्ध नहीं हैं।
  • Arbitrum-आधारित Virtual Environments। Arbitrum internals के कारण eth_call के माध्यम से किए गए Cheatcode calls काम नहीं करते। Transactions, gas estimates, और simulations अपेक्षित रूप से काम करते हैं।

यह भी देखें

  • Admin RPC, transaction के बाहर से state manipulation के लिए equivalent JSON-RPC methods।
  • Foundry cheatcode tutorial, एक reusable cheatcode playground deploy करने के लिए end-to-end walkthrough।