foundry_cheatcodes_spec/vm.rs
1// We don't document function parameters individually so we can't enable `missing_docs` for this
2// module. Instead, we emit custom diagnostics in `#[derive(Cheatcode)]`.
3#![allow(missing_docs)]
4
5use super::*;
6use crate::Vm::ForgeContext;
7use alloy_sol_types::sol;
8use foundry_macros::Cheatcode;
9
10sol! {
11// Cheatcodes are marked as view/pure/none using the following rules:
12// 0. A call's observable behaviour includes its return value, logs, reverts and state writes,
13// 1. If you can influence a later call's observable behaviour, you're neither `view` nor `pure`
14// (you are modifying some state be it the EVM, interpreter, filesystem, etc),
15// 2. Otherwise if you can be influenced by an earlier call, or if reading some state, you're `view`,
16// 3. Otherwise you're `pure`.
17
18/// Foundry cheatcodes interface.
19#[derive(Debug, Cheatcode)] // Keep this list small to avoid unnecessary bloat.
20#[sol(abi)]
21interface Vm {
22 // ======== Types ========
23
24 /// Error thrown by cheatcodes.
25 error CheatcodeError(string message);
26
27 /// A modification applied to either `msg.sender` or `tx.origin`. Returned by `readCallers`.
28 enum CallerMode {
29 /// No caller modification is currently active.
30 None,
31 /// A one time broadcast triggered by a `vm.broadcast()` call is currently active.
32 Broadcast,
33 /// A recurrent broadcast triggered by a `vm.startBroadcast()` call is currently active.
34 RecurrentBroadcast,
35 /// A one time prank triggered by a `vm.prank()` call is currently active.
36 Prank,
37 /// A recurrent prank triggered by a `vm.startPrank()` call is currently active.
38 RecurrentPrank,
39 }
40
41 /// The kind of account access that occurred.
42 enum AccountAccessKind {
43 /// The account was called.
44 Call,
45 /// The account was called via delegatecall.
46 DelegateCall,
47 /// The account was called via callcode.
48 CallCode,
49 /// The account was called via staticcall.
50 StaticCall,
51 /// The account was created.
52 Create,
53 /// The account was selfdestructed.
54 SelfDestruct,
55 /// Synthetic access indicating the current context has resumed after a previous sub-context (AccountAccess).
56 Resume,
57 /// The account's balance was read.
58 Balance,
59 /// The account's codesize was read.
60 Extcodesize,
61 /// The account's codehash was read.
62 Extcodehash,
63 /// The account's code was copied.
64 Extcodecopy,
65 }
66
67 /// Forge execution contexts.
68 enum ForgeContext {
69 /// Test group execution context (test, coverage or snapshot).
70 TestGroup,
71 /// `forge test` execution context.
72 Test,
73 /// `forge coverage` execution context.
74 Coverage,
75 /// `forge snapshot` execution context.
76 Snapshot,
77 /// Script group execution context (dry run, broadcast or resume).
78 ScriptGroup,
79 /// `forge script` execution context.
80 ScriptDryRun,
81 /// `forge script --broadcast` execution context.
82 ScriptBroadcast,
83 /// `forge script --resume` execution context.
84 ScriptResume,
85 /// Unknown `forge` execution context.
86 Unknown,
87 }
88
89 /// An Ethereum log. Returned by `getRecordedLogs`.
90 struct Log {
91 /// The topics of the log, including the signature, if any.
92 bytes32[] topics;
93 /// The raw data of the log.
94 bytes data;
95 /// The address of the log's emitter.
96 address emitter;
97 }
98
99 /// Gas used. Returned by `lastCallGas` and `lastFrameGas`.
100 struct Gas {
101 /// The gas limit of the call.
102 uint64 gasLimit;
103 /// The total gas used.
104 uint64 gasTotalUsed;
105 /// DEPRECATED: The amount of gas used for memory expansion. Ref: <https://github.com/foundry-rs/foundry/pull/7934#pullrequestreview-2069236939>
106 uint64 gasMemoryUsed;
107 /// The amount of gas refunded.
108 int64 gasRefunded;
109 /// The amount of gas remaining.
110 uint64 gasRemaining;
111 }
112
113 /// An RPC URL and its alias. Returned by `rpcUrlStructs`.
114 struct Rpc {
115 /// The alias of the RPC URL.
116 string key;
117 /// The RPC URL.
118 string url;
119 }
120
121 /// An RPC log object. Returned by `eth_getLogs`.
122 struct EthGetLogs {
123 /// The address of the log's emitter.
124 address emitter;
125 /// The topics of the log, including the signature, if any.
126 bytes32[] topics;
127 /// The raw data of the log.
128 bytes data;
129 /// The block hash.
130 bytes32 blockHash;
131 /// The block number.
132 uint64 blockNumber;
133 /// The transaction hash.
134 bytes32 transactionHash;
135 /// The transaction index in the block.
136 uint64 transactionIndex;
137 /// The log index.
138 uint256 logIndex;
139 /// Whether the log was removed.
140 bool removed;
141 }
142
143 /// A single entry in a directory listing. Returned by `readDir`.
144 struct DirEntry {
145 /// The error message, if any.
146 string errorMessage;
147 /// The path of the entry.
148 string path;
149 /// The depth of the entry.
150 uint64 depth;
151 /// Whether the entry is a directory.
152 bool isDir;
153 /// Whether the entry is a symlink.
154 bool isSymlink;
155 }
156
157 /// Metadata information about a file.
158 ///
159 /// This structure is returned from the `fsMetadata` function and represents known
160 /// metadata about a file such as its permissions, size, modification
161 /// times, etc.
162 struct FsMetadata {
163 /// True if this metadata is for a directory.
164 bool isDir;
165 /// True if this metadata is for a symlink.
166 bool isSymlink;
167 /// The size of the file, in bytes, this metadata is for.
168 uint256 length;
169 /// True if this metadata is for a readonly (unwritable) file.
170 bool readOnly;
171 /// The last modification time listed in this metadata.
172 uint256 modified;
173 /// The last access time of this metadata.
174 uint256 accessed;
175 /// The creation time listed in this metadata.
176 uint256 created;
177 }
178
179 /// A wallet with a public and private key.
180 struct Wallet {
181 /// The wallet's address.
182 address addr;
183 /// The wallet's public key `X`.
184 uint256 publicKeyX;
185 /// The wallet's public key `Y`.
186 uint256 publicKeyY;
187 /// The wallet's private key.
188 uint256 privateKey;
189 }
190
191 /// The result of a `tryFfi` call.
192 struct FfiResult {
193 /// The exit code of the call.
194 int32 exitCode;
195 /// The optionally hex-decoded `stdout` data.
196 bytes stdout;
197 /// The `stderr` data.
198 bytes stderr;
199 }
200
201 /// Information on the chain and fork.
202 struct ChainInfo {
203 /// The fork identifier. Set to zero if no fork is active.
204 uint256 forkId;
205 /// The chain ID of the current fork.
206 uint256 chainId;
207 }
208
209 /// Information about a blockchain.
210 struct Chain {
211 /// The chain name.
212 string name;
213 /// The chain's Chain ID.
214 uint256 chainId;
215 /// The chain's alias. (i.e. what gets specified in `foundry.toml`).
216 string chainAlias;
217 /// A default RPC endpoint for this chain.
218 string rpcUrl;
219 }
220
221 /// The storage accessed during an `AccountAccess`.
222 struct StorageAccess {
223 /// The account whose storage was accessed.
224 address account;
225 /// The slot that was accessed.
226 bytes32 slot;
227 /// If the access was a write.
228 bool isWrite;
229 /// The previous value of the slot.
230 bytes32 previousValue;
231 /// The new value of the slot.
232 bytes32 newValue;
233 /// If the access was reverted.
234 bool reverted;
235 }
236
237 /// An EIP-2930 access list item.
238 struct AccessListItem {
239 /// The address to be added in access list.
240 address target;
241 /// The storage keys to be added in access list.
242 bytes32[] storageKeys;
243 }
244
245 /// The result of a `stopAndReturnStateDiff` call.
246 struct AccountAccess {
247 /// The chain and fork the access occurred.
248 ChainInfo chainInfo;
249 /// The kind of account access that determines what the account is.
250 /// If kind is Call, DelegateCall, StaticCall or CallCode, then the account is the callee.
251 /// If kind is Create, then the account is the newly created account.
252 /// If kind is SelfDestruct, then the account is the selfdestruct recipient.
253 /// If kind is a Resume, then account represents a account context that has resumed.
254 AccountAccessKind kind;
255 /// The account that was accessed.
256 /// It's either the account created, callee or a selfdestruct recipient for CREATE, CALL or SELFDESTRUCT.
257 address account;
258 /// What accessed the account.
259 address accessor;
260 /// If the account was initialized or empty prior to the access.
261 /// An account is considered initialized if it has code, a
262 /// non-zero nonce, or a non-zero balance.
263 bool initialized;
264 /// The previous balance of the accessed account.
265 uint256 oldBalance;
266 /// The potential new balance of the accessed account.
267 /// That is, all balance changes are recorded here, even if reverts occurred.
268 uint256 newBalance;
269 /// Code of the account deployed by CREATE.
270 bytes deployedCode;
271 /// Value passed along with the account access
272 uint256 value;
273 /// Input data provided to the CREATE or CALL
274 bytes data;
275 /// If this access reverted in either the current or parent context.
276 bool reverted;
277 /// An ordered list of storage accesses made during an account access operation.
278 StorageAccess[] storageAccesses;
279 /// Call depth traversed during the recording of state differences
280 uint64 depth;
281 /// The previous nonce of the accessed account.
282 uint64 oldNonce;
283 /// The new nonce of the accessed account.
284 uint64 newNonce;
285 }
286
287 /// The result of the `stopDebugTraceRecording` call
288 struct DebugStep {
289 /// The stack before executing the step of the run.
290 /// stack\[0\] represents the top of the stack.
291 /// and only stack data relevant to the opcode execution is contained.
292 uint256[] stack;
293 /// The memory input data before executing the step of the run.
294 /// only input data relevant to the opcode execution is contained.
295 ///
296 /// e.g. for MLOAD, it will have memory\[offset:offset+32\] copied here.
297 /// the offset value can be get by the stack data.
298 bytes memoryInput;
299 /// The opcode that was accessed.
300 uint8 opcode;
301 /// The call depth of the step.
302 uint64 depth;
303 /// Whether the call end up with out of gas error.
304 bool isOutOfGas;
305 /// The contract address where the opcode is running
306 address contractAddr;
307 }
308
309 /// The transaction type (`txType`) of the broadcast.
310 enum BroadcastTxType {
311 /// Represents a CALL broadcast tx.
312 Call,
313 /// Represents a CREATE broadcast tx.
314 Create,
315 /// Represents a CREATE2 broadcast tx.
316 Create2
317 }
318
319 /// Represents a transaction's broadcast details.
320 struct BroadcastTxSummary {
321 /// The hash of the transaction that was broadcasted
322 bytes32 txHash;
323 /// Represent the type of transaction among CALL, CREATE, CREATE2
324 BroadcastTxType txType;
325 /// The address of the contract that was called or created.
326 /// This is address of the contract that is created if the txType is CREATE or CREATE2.
327 address contractAddress;
328 /// The block number the transaction landed in.
329 uint64 blockNumber;
330 /// Status of the transaction, retrieved from the transaction receipt.
331 bool success;
332 }
333
334 /// Holds a signed EIP-7702 authorization for an authority account to delegate to an implementation.
335 struct SignedDelegation {
336 /// The y-parity of the recovered secp256k1 signature (0 or 1).
337 uint8 v;
338 /// First 32 bytes of the signature.
339 bytes32 r;
340 /// Second 32 bytes of the signature.
341 bytes32 s;
342 /// The current nonce of the authority account at signing time.
343 /// Used to ensure signature can't be replayed after account nonce changes.
344 uint64 nonce;
345 /// Address of the contract implementation that will be delegated to.
346 /// Gets encoded into delegation code: 0xef0100 || implementation.
347 address implementation;
348 }
349
350 /// Represents a "potential" revert reason from a single subsequent call when using `vm.assumeNoReverts`.
351 /// Reverts that match will result in a FOUNDRY::ASSUME rejection, whereas unmatched reverts will be surfaced
352 /// as normal.
353 struct PotentialRevert {
354 /// The allowed origin of the revert opcode; address(0) allows reverts from any address
355 address reverter;
356 /// When true, only matches on the beginning of the revert data, otherwise, matches on entire revert data
357 bool partialMatch;
358 /// The data to use to match encountered reverts
359 bytes revertData;
360 }
361
362 // ======== EVM ========
363
364 /// Gets the address for a given private key.
365 #[cheatcode(group = Evm, safety = Safe)]
366 function addr(uint256 privateKey) external pure returns (address keyAddr);
367
368 /// Dump a genesis JSON file's `allocs` to disk.
369 #[cheatcode(group = Evm, safety = Unsafe)]
370 function dumpState(string calldata pathToStateJson) external;
371
372 /// Gets the nonce of an account.
373 #[cheatcode(group = Evm, safety = Safe)]
374 function getNonce(address account) external view returns (uint64 nonce);
375
376 /// Get the nonce of a `Wallet`.
377 #[cheatcode(group = Evm, safety = Safe)]
378 function getNonce(Wallet calldata wallet) external view returns (uint64 nonce);
379
380 /// Loads a storage slot from an address.
381 #[cheatcode(group = Evm, safety = Safe)]
382 function load(address target, bytes32 slot) external view returns (bytes32 data);
383
384 /// Load a genesis JSON file's `allocs` into the in-memory EVM state.
385 #[cheatcode(group = Evm, safety = Unsafe)]
386 function loadAllocs(string calldata pathToAllocsJson) external;
387
388 // -------- Record Debug Traces --------
389
390 /// Records the debug trace during the run.
391 #[cheatcode(group = Evm, safety = Safe)]
392 function startDebugTraceRecording() external;
393
394 /// Stop debug trace recording and returns the recorded debug trace.
395 #[cheatcode(group = Evm, safety = Safe)]
396 function stopAndReturnDebugTraceRecording() external returns (DebugStep[] memory step);
397
398
399 /// Clones a source account code, state, balance and nonce to a target account and updates in-memory EVM state.
400 #[cheatcode(group = Evm, safety = Unsafe)]
401 function cloneAccount(address source, address target) external;
402
403 // -------- Record Storage --------
404
405 /// Records all storage reads and writes. Use `accesses` to get the recorded data.
406 /// Subsequent calls to `record` will clear the previous data.
407 #[cheatcode(group = Evm, safety = Safe)]
408 function record() external;
409
410 /// Stops recording storage reads and writes.
411 #[cheatcode(group = Evm, safety = Safe)]
412 function stopRecord() external;
413
414 /// Gets all accessed reads and write slot from a `vm.record` session, for a given address.
415 #[cheatcode(group = Evm, safety = Safe)]
416 function accesses(address target) external view returns (bytes32[] memory readSlots, bytes32[] memory writeSlots);
417
418 /// Record all account accesses as part of CREATE, CALL or SELFDESTRUCT opcodes in order,
419 /// along with the context of the calls
420 #[cheatcode(group = Evm, safety = Safe)]
421 function startStateDiffRecording() external;
422
423 /// Returns an ordered array of all account accesses from a `vm.startStateDiffRecording` session.
424 #[cheatcode(group = Evm, safety = Safe)]
425 function stopAndReturnStateDiff() external returns (AccountAccess[] memory accountAccesses);
426
427 /// Returns state diffs from current `vm.startStateDiffRecording` session.
428 #[cheatcode(group = Evm, safety = Safe)]
429 function getStateDiff() external view returns (string memory diff);
430
431 /// Returns state diffs from current `vm.startStateDiffRecording` session, in json format.
432 #[cheatcode(group = Evm, safety = Safe)]
433 function getStateDiffJson() external view returns (string memory diff);
434
435 /// Returns an array of storage slots occupied by the specified variable.
436 #[cheatcode(group = Evm, safety = Safe)]
437 function getStorageSlots(address target, string calldata variableName) external view returns (uint256[] memory slots);
438
439 /// Returns an array of `StorageAccess` from current `vm.stateStateDiffRecording` session
440 #[cheatcode(group = Evm, safety = Safe)]
441 function getStorageAccesses() external view returns (StorageAccess[] memory storageAccesses);
442
443 // -------- Recording Map Writes --------
444
445 /// Starts recording all map SSTOREs for later retrieval.
446 #[cheatcode(group = Evm, safety = Safe)]
447 function startMappingRecording() external;
448
449 /// Stops recording all map SSTOREs for later retrieval and clears the recorded data.
450 #[cheatcode(group = Evm, safety = Safe)]
451 function stopMappingRecording() external;
452
453 /// Gets the number of elements in the mapping at the given slot, for a given address.
454 #[cheatcode(group = Evm, safety = Safe)]
455 function getMappingLength(address target, bytes32 mappingSlot) external view returns (uint256 length);
456
457 /// Gets the elements at index idx of the mapping at the given slot, for a given address. The
458 /// index must be less than the length of the mapping (i.e. the number of keys in the mapping).
459 #[cheatcode(group = Evm, safety = Safe)]
460 function getMappingSlotAt(address target, bytes32 mappingSlot, uint256 idx) external view returns (bytes32 value);
461
462 /// Gets the map key and parent of a mapping at a given slot, for a given address.
463 #[cheatcode(group = Evm, safety = Safe)]
464 function getMappingKeyAndParentOf(address target, bytes32 elementSlot)
465 external
466 view
467 returns (bool found, bytes32 key, bytes32 parent);
468
469 // -------- Block and Transaction Properties --------
470
471 /// Gets the current `block.chainid` of the currently selected environment.
472 /// You should use this instead of `block.chainid` if you use `vm.selectFork` or `vm.createSelectFork`, as `block.chainid` could be assumed
473 /// to be constant across a transaction, and as a result will get optimized out by the compiler.
474 /// See https://github.com/foundry-rs/foundry/issues/6180
475 #[cheatcode(group = Evm, safety = Safe)]
476 function getChainId() external view returns (uint256 blockChainId);
477
478 /// Sets `block.chainid`.
479 #[cheatcode(group = Evm, safety = Unsafe)]
480 function chainId(uint256 newChainId) external;
481
482 /// Sets `block.coinbase`.
483 #[cheatcode(group = Evm, safety = Unsafe)]
484 function coinbase(address newCoinbase) external;
485
486 /// Sets `block.difficulty`.
487 /// Not available on EVM versions from Paris onwards. Use `prevrandao` instead.
488 /// Reverts if used on unsupported EVM versions.
489 #[cheatcode(group = Evm, safety = Unsafe)]
490 function difficulty(uint256 newDifficulty) external;
491
492 /// Sets `block.basefee`.
493 #[cheatcode(group = Evm, safety = Unsafe)]
494 function fee(uint256 newBasefee) external;
495
496 /// Sets `block.prevrandao`.
497 /// Not available on EVM versions before Paris. Use `difficulty` instead.
498 /// If used on unsupported EVM versions it will revert.
499 #[cheatcode(group = Evm, safety = Unsafe)]
500 function prevrandao(bytes32 newPrevrandao) external;
501 /// Sets `block.prevrandao`.
502 /// Not available on EVM versions before Paris. Use `difficulty` instead.
503 /// If used on unsupported EVM versions it will revert.
504 #[cheatcode(group = Evm, safety = Unsafe)]
505 function prevrandao(uint256 newPrevrandao) external;
506
507 /// Sets the blobhashes in the transaction.
508 /// Not available on EVM versions before Cancun.
509 /// If used on unsupported EVM versions it will revert.
510 #[cheatcode(group = Evm, safety = Unsafe)]
511 function blobhashes(bytes32[] calldata hashes) external;
512
513 /// Gets the blockhashes from the current transaction.
514 /// Not available on EVM versions before Cancun.
515 /// If used on unsupported EVM versions it will revert.
516 #[cheatcode(group = Evm, safety = Unsafe)]
517 function getBlobhashes() external view returns (bytes32[] memory hashes);
518
519 /// Sets `block.height`.
520 #[cheatcode(group = Evm, safety = Unsafe)]
521 function roll(uint256 newHeight) external;
522
523 /// Gets the current `block.number`.
524 /// You should use this instead of `block.number` if you use `vm.roll`, as `block.number` is assumed to be constant across a transaction,
525 /// and as a result will get optimized out by the compiler.
526 /// See https://github.com/foundry-rs/foundry/issues/6180
527 #[cheatcode(group = Evm, safety = Safe)]
528 function getBlockNumber() external view returns (uint256 height);
529
530 /// Sets `tx.gasprice`.
531 #[cheatcode(group = Evm, safety = Unsafe)]
532 function txGasPrice(uint256 newGasPrice) external;
533
534 /// Sets `block.timestamp`.
535 #[cheatcode(group = Evm, safety = Unsafe)]
536 function warp(uint256 newTimestamp) external;
537
538 /// Gets the current `block.timestamp`.
539 /// You should use this instead of `block.timestamp` if you use `vm.warp`, as `block.timestamp` is assumed to be constant across a transaction,
540 /// and as a result will get optimized out by the compiler.
541 /// See https://github.com/foundry-rs/foundry/issues/6180
542 #[cheatcode(group = Evm, safety = Safe)]
543 function getBlockTimestamp() external view returns (uint256 timestamp);
544
545 /// Gets the RLP encoded block header for a given block number.
546 /// Returns the block header in the same format as `cast block <block_number> --raw`.
547 #[cheatcode(group = Evm, safety = Safe)]
548 function getRawBlockHeader(uint256 blockNumber) external view returns (bytes memory rlpHeader);
549
550 /// Sets `block.blobbasefee`
551 #[cheatcode(group = Evm, safety = Unsafe)]
552 function blobBaseFee(uint256 newBlobBaseFee) external;
553
554 /// Gets the current `block.blobbasefee`.
555 /// You should use this instead of `block.blobbasefee` if you use `vm.blobBaseFee`, as `block.blobbasefee` is assumed to be constant across a transaction,
556 /// and as a result will get optimized out by the compiler.
557 /// See https://github.com/foundry-rs/foundry/issues/6180
558 #[cheatcode(group = Evm, safety = Safe)]
559 function getBlobBaseFee() external view returns (uint256 blobBaseFee);
560
561 /// Set blockhash for the current block.
562 /// It only sets the blockhash for blocks where `block.number - 256 <= number < block.number`.
563 #[cheatcode(group = Evm, safety = Unsafe)]
564 function setBlockhash(uint256 blockNumber, bytes32 blockHash) external;
565
566 /// Executes an RLP-encoded signed transaction with full EVM semantics (like `--isolate` mode).
567 /// The transaction is decoded from EIP-2718 format (type byte prefix + RLP payload) or legacy RLP.
568 /// Returns the execution output bytes.
569 ///
570 /// This cheatcode is not allowed in `forge script` contexts.
571 #[cheatcode(group = Evm, safety = Unsafe)]
572 function executeTransaction(bytes calldata rawTx) external returns (bytes memory);
573
574 // -------- Account State --------
575
576 /// Sets an address' balance.
577 #[cheatcode(group = Evm, safety = Unsafe)]
578 function deal(address account, uint256 newBalance) external;
579
580 /// Sets an address' code.
581 #[cheatcode(group = Evm, safety = Unsafe)]
582 function etch(address target, bytes calldata newRuntimeBytecode) external;
583
584 /// Resets the nonce of an account to 0 for EOAs and 1 for contract accounts.
585 #[cheatcode(group = Evm, safety = Unsafe)]
586 function resetNonce(address account) external;
587
588 /// Sets the nonce of an account. Must be higher than the current nonce of the account.
589 #[cheatcode(group = Evm, safety = Unsafe)]
590 function setNonce(address account, uint64 newNonce) external;
591
592 /// Sets the nonce of an account to an arbitrary value.
593 #[cheatcode(group = Evm, safety = Unsafe)]
594 function setNonceUnsafe(address account, uint64 newNonce) external;
595
596 /// Stores a value to an address' storage slot.
597 #[cheatcode(group = Evm, safety = Unsafe)]
598 function store(address target, bytes32 slot, bytes32 value) external;
599
600 /// Sets a TIP-20 token's logo URI directly in storage.
601 /// This bypasses the token admin check, but still validates the URI against T5 constraints.
602 #[cheatcode(group = Evm, safety = Unsafe)]
603 function setTip20LogoURI(address token, string calldata newLogoURI) external;
604
605 /// Sets a TIP-20 token's logo URI directly in storage.
606 /// This bypasses the token admin check, but still validates the URI against T5 constraints.
607 #[cheatcode(group = Evm, safety = Unsafe)]
608 function setLogoURI(address token, string calldata newLogoURI) external;
609
610 /// Marks the slots of an account and the account address as cold.
611 #[cheatcode(group = Evm, safety = Unsafe)]
612 function cool(address target) external;
613
614 /// Utility cheatcode to set an EIP-2930 access list for all subsequent transactions.
615 #[cheatcode(group = Evm, safety = Unsafe)]
616 function accessList(AccessListItem[] calldata access) external;
617
618 /// Utility cheatcode to remove any EIP-2930 access list set by `accessList` cheatcode.
619 #[cheatcode(group = Evm, safety = Unsafe)]
620 function noAccessList() external;
621
622 /// Utility cheatcode to mark specific storage slot as warm, simulating a prior read.
623 #[cheatcode(group = Evm, safety = Unsafe)]
624 function warmSlot(address target, bytes32 slot) external;
625
626 /// Utility cheatcode to mark specific storage slot as cold, simulating no prior read.
627 #[cheatcode(group = Evm, safety = Unsafe)]
628 function coolSlot(address target, bytes32 slot) external;
629
630 /// Returns true if isolated test execution is enabled.
631 #[cheatcode(group = Evm, safety = Safe)]
632 function isIsolateMode() external view returns (bool result);
633
634 /// Returns the test or script execution evm version.
635 ///
636 /// **Note:** The execution evm version is not the same as the compilation one.
637 #[cheatcode(group = Evm, safety = Safe)]
638 function getEvmVersion() external pure returns (string memory evm);
639
640 /// Set the exact test or script execution evm version, e.g. `berlin`, `cancun`.
641 ///
642 /// **Note:** The execution evm version is not the same as the compilation one.
643 #[cheatcode(group = Evm, safety = Safe)]
644 function setEvmVersion(string calldata evm) external;
645
646 /// Returns `true` if `spender` is on the active Tempo hardfork's implicit-approval list,
647 /// meaning it can pull TIP-20 tokens from `msg.sender` without a prior `approve()`.
648 /// Returns `false` on non-Tempo networks.
649 #[cheatcode(group = Evm, safety = Safe)]
650 function isImplicitlyApproved(address spender) external view returns (bool implicitlyApproved);
651
652 /// Skips a fuzz/invariant input unless `spender` is implicitly approved.
653 #[cheatcode(group = Testing, safety = Safe)]
654 function assumeImplicitApproval(address spender) external view;
655
656 // -------- Call Manipulation --------
657 // --- Mocks ---
658
659 /// Clears all mocked calls.
660 #[cheatcode(group = Evm, safety = Unsafe)]
661 function clearMockedCalls() external;
662
663 /// Mocks a call to an address, returning specified data.
664 /// Calldata can either be strict or a partial match, e.g. if you only
665 /// pass a Solidity selector to the expected calldata, then the entire Solidity
666 /// function will be mocked.
667 #[cheatcode(group = Evm, safety = Unsafe)]
668 function mockCall(address callee, bytes calldata data, bytes calldata returnData) external;
669
670 /// Mocks a call to an address with a specific `msg.value`, returning specified data.
671 /// Calldata match takes precedence over `msg.value` in case of ambiguity.
672 #[cheatcode(group = Evm, safety = Unsafe)]
673 function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external;
674
675 /// Mocks a call to an address, returning specified data.
676 /// Calldata can either be strict or a partial match, e.g. if you only
677 /// pass a Solidity selector to the expected calldata, then the entire Solidity
678 /// function will be mocked.
679 ///
680 /// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.
681 #[cheatcode(group = Evm, safety = Unsafe)]
682 function mockCall(address callee, bytes4 data, bytes calldata returnData) external;
683
684 /// Mocks a call to an address with a specific `msg.value`, returning specified data.
685 /// Calldata match takes precedence over `msg.value` in case of ambiguity.
686 ///
687 /// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.
688 #[cheatcode(group = Evm, safety = Unsafe)]
689 function mockCall(address callee, uint256 msgValue, bytes4 data, bytes calldata returnData) external;
690
691 /// Mocks a call to an address, returning specified data.
692 /// Calldata can either be strict or a partial match, e.g. if you only
693 /// pass a Solidity selector to the expected calldata, then the entire Solidity
694 /// function will be mocked.
695 ///
696 /// Overload to control whether code is injected into `callee`. The other overloads etch a
697 /// single byte into an empty account to circumvent Solidity's `extcodesize` check, with the
698 /// side effect that unmocked calls to it no longer revert; `injectCode = false` leaves the
699 /// account codeless, so unmocked calls to it revert in the caller. Mocked calls that return
700 /// data still succeed, as Solidity checks `returndatasize()` instead of `extcodesize()` when
701 /// return data is expected, but mocked calls to functions without return values may still
702 /// revert in the caller due to the `extcodesize` check.
703 #[cheatcode(group = Evm, safety = Unsafe)]
704 function mockCall(address callee, bytes calldata data, bytes calldata returnData, bool injectCode) external;
705
706 /// Mocks multiple calls to an address, returning specified data for each call.
707 #[cheatcode(group = Evm, safety = Unsafe)]
708 function mockCalls(address callee, bytes calldata data, bytes[] calldata returnData) external;
709
710 /// Mocks multiple calls to an address with a specific `msg.value`, returning specified data for each call.
711 #[cheatcode(group = Evm, safety = Unsafe)]
712 function mockCalls(address callee, uint256 msgValue, bytes calldata data, bytes[] calldata returnData) external;
713
714 /// Reverts a call to an address with specified revert data.
715 #[cheatcode(group = Evm, safety = Unsafe)]
716 function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external;
717
718 /// Reverts a call to an address with a specific `msg.value`, with specified revert data.
719 #[cheatcode(group = Evm, safety = Unsafe)]
720 function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData)
721 external;
722
723 /// Reverts a call to an address with specified revert data.
724 ///
725 /// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.
726 #[cheatcode(group = Evm, safety = Unsafe)]
727 function mockCallRevert(address callee, bytes4 data, bytes calldata revertData) external;
728
729 /// Reverts a call to an address with a specific `msg.value`, with specified revert data.
730 ///
731 /// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.
732 #[cheatcode(group = Evm, safety = Unsafe)]
733 function mockCallRevert(address callee, uint256 msgValue, bytes4 data, bytes calldata revertData)
734 external;
735
736 /// Whenever a call is made to `callee` with calldata `data`, this cheatcode instead calls
737 /// `target` with the same calldata. This functionality is similar to a delegate call made to
738 /// `target` contract from `callee`.
739 /// Can be used to substitute a call to a function with another implementation that captures
740 /// the primary logic of the original function but is easier to reason about.
741 /// If calldata is not a strict match then partial match by selector is attempted.
742 #[cheatcode(group = Evm, safety = Unsafe)]
743 function mockFunction(address callee, address target, bytes calldata data) external;
744
745 // --- Impersonation (pranks) ---
746
747 /// Sets the *next* call's `msg.sender` to be the input address.
748 #[cheatcode(group = Evm, safety = Unsafe)]
749 function prank(address msgSender) external;
750
751 /// Sets all subsequent calls' `msg.sender` to be the input address until `stopPrank` is called.
752 #[cheatcode(group = Evm, safety = Unsafe)]
753 function startPrank(address msgSender) external;
754
755 /// Sets the *next* call's `msg.sender` to be the input address, and the `tx.origin` to be the second input.
756 #[cheatcode(group = Evm, safety = Unsafe)]
757 function prank(address msgSender, address txOrigin) external;
758
759 /// Sets all subsequent calls' `msg.sender` to be the input address until `stopPrank` is called, and the `tx.origin` to be the second input.
760 #[cheatcode(group = Evm, safety = Unsafe)]
761 function startPrank(address msgSender, address txOrigin) external;
762
763 /// Sets the *next* delegate call's `msg.sender` to be the input address.
764 #[cheatcode(group = Evm, safety = Unsafe)]
765 function prank(address msgSender, bool delegateCall) external;
766
767 /// Sets all subsequent delegate calls' `msg.sender` to be the input address until `stopPrank` is called.
768 #[cheatcode(group = Evm, safety = Unsafe)]
769 function startPrank(address msgSender, bool delegateCall) external;
770
771 /// Sets the *next* delegate call's `msg.sender` to be the input address, and the `tx.origin` to be the second input.
772 #[cheatcode(group = Evm, safety = Unsafe)]
773 function prank(address msgSender, address txOrigin, bool delegateCall) external;
774
775 /// Sets all subsequent delegate calls' `msg.sender` to be the input address until `stopPrank` is called, and the `tx.origin` to be the second input.
776 #[cheatcode(group = Evm, safety = Unsafe)]
777 function startPrank(address msgSender, address txOrigin, bool delegateCall) external;
778
779 /// Resets subsequent calls' `msg.sender` to be `address(this)`.
780 #[cheatcode(group = Evm, safety = Unsafe)]
781 function stopPrank() external;
782
783 /// Reads the current `msg.sender` and `tx.origin` from state and reports if there is any active caller modification.
784 #[cheatcode(group = Evm, safety = Unsafe)]
785 function readCallers() external view returns (CallerMode callerMode, address msgSender, address txOrigin);
786
787 // ----- Arbitrary Snapshots -----
788
789 /// Snapshot capture an arbitrary numerical value by name.
790 /// The group name is derived from the contract name.
791 #[cheatcode(group = Evm, safety = Unsafe)]
792 function snapshotValue(string calldata name, uint256 value) external;
793
794 /// Snapshot capture an arbitrary numerical value by name in a group.
795 #[cheatcode(group = Evm, safety = Unsafe)]
796 function snapshotValue(string calldata group, string calldata name, uint256 value) external;
797
798 // -------- Gas Snapshots --------
799
800 /// DEPRECATED: use `snapshotGasLastFrame` instead.
801 /// Snapshot capture the gas usage of the last call by name from the callee perspective.
802 #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `snapshotGasLastFrame`")))]
803 function snapshotGasLastCall(string calldata name) external returns (uint256 gasUsed);
804
805 /// DEPRECATED: use `snapshotGasLastFrame` instead.
806 /// Snapshot capture the gas usage of the last call by name in a group from the callee perspective.
807 #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `snapshotGasLastFrame`")))]
808 function snapshotGasLastCall(string calldata group, string calldata name) external returns (uint256 gasUsed);
809
810 /// Snapshot capture the gas usage of the last call or create by name from the callee perspective.
811 #[cheatcode(group = Evm, safety = Unsafe)]
812 function snapshotGasLastFrame(string calldata name) external returns (uint256 gasUsed);
813
814 /// Snapshot capture the gas usage of the last call or create by name in a group from the callee perspective.
815 #[cheatcode(group = Evm, safety = Unsafe)]
816 function snapshotGasLastFrame(string calldata group, string calldata name) external returns (uint256 gasUsed);
817
818 /// Start a snapshot capture of the current gas usage by name.
819 /// The group name is derived from the contract name.
820 #[cheatcode(group = Evm, safety = Unsafe)]
821 function startSnapshotGas(string calldata name) external;
822
823 /// Start a snapshot capture of the current gas usage by name in a group.
824 #[cheatcode(group = Evm, safety = Unsafe)]
825 function startSnapshotGas(string calldata group, string calldata name) external;
826
827 /// Stop the snapshot capture of the current gas by latest snapshot name, capturing the gas used since the start.
828 #[cheatcode(group = Evm, safety = Unsafe)]
829 function stopSnapshotGas() external returns (uint256 gasUsed);
830
831 /// Stop the snapshot capture of the current gas usage by name, capturing the gas used since the start.
832 /// The group name is derived from the contract name.
833 #[cheatcode(group = Evm, safety = Unsafe)]
834 function stopSnapshotGas(string calldata name) external returns (uint256 gasUsed);
835
836 /// Stop the snapshot capture of the current gas usage by name in a group, capturing the gas used since the start.
837 #[cheatcode(group = Evm, safety = Unsafe)]
838 function stopSnapshotGas(string calldata group, string calldata name) external returns (uint256 gasUsed);
839
840 // -------- State Snapshots --------
841
842 /// `snapshot` is being deprecated in favor of `snapshotState`. It will be removed in future versions.
843 #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `snapshotState`")))]
844 function snapshot() external returns (uint256 snapshotId);
845
846 /// Snapshot the current state of the evm.
847 /// Returns the ID of the snapshot that was created.
848 /// To revert a snapshot use `revertToState`.
849 #[cheatcode(group = Evm, safety = Unsafe)]
850 function snapshotState() external returns (uint256 snapshotId);
851
852 /// `revertTo` is being deprecated in favor of `revertToState`. It will be removed in future versions.
853 #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `revertToState`")))]
854 function revertTo(uint256 snapshotId) external returns (bool success);
855
856 /// Revert the state of the EVM to a previous snapshot
857 /// Takes the snapshot ID to revert to.
858 ///
859 /// Returns `true` if the snapshot was successfully reverted.
860 /// Returns `false` if the snapshot does not exist.
861 ///
862 /// **Note:** This does not automatically delete the snapshot. To delete the snapshot use `deleteStateSnapshot`.
863 #[cheatcode(group = Evm, safety = Unsafe)]
864 function revertToState(uint256 snapshotId) external returns (bool success);
865
866 /// `revertToAndDelete` is being deprecated in favor of `revertToStateAndDelete`. It will be removed in future versions.
867 #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `revertToStateAndDelete`")))]
868 function revertToAndDelete(uint256 snapshotId) external returns (bool success);
869
870 /// Revert the state of the EVM to a previous snapshot and automatically deletes the snapshots
871 /// Takes the snapshot ID to revert to.
872 ///
873 /// Returns `true` if the snapshot was successfully reverted and deleted.
874 /// Returns `false` if the snapshot does not exist.
875 #[cheatcode(group = Evm, safety = Unsafe)]
876 function revertToStateAndDelete(uint256 snapshotId) external returns (bool success);
877
878 /// `deleteSnapshot` is being deprecated in favor of `deleteStateSnapshot`. It will be removed in future versions.
879 #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `deleteStateSnapshot`")))]
880 function deleteSnapshot(uint256 snapshotId) external returns (bool success);
881
882 /// Removes the snapshot with the given ID created by `snapshot`.
883 /// Takes the snapshot ID to delete.
884 ///
885 /// Returns `true` if the snapshot was successfully deleted.
886 /// Returns `false` if the snapshot does not exist.
887 #[cheatcode(group = Evm, safety = Unsafe)]
888 function deleteStateSnapshot(uint256 snapshotId) external returns (bool success);
889
890 /// `deleteSnapshots` is being deprecated in favor of `deleteStateSnapshots`. It will be removed in future versions.
891 #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `deleteStateSnapshots`")))]
892 function deleteSnapshots() external;
893
894 /// Removes _all_ snapshots previously created by `snapshot`.
895 #[cheatcode(group = Evm, safety = Unsafe)]
896 function deleteStateSnapshots() external;
897
898 // -------- Forking --------
899 // --- Creation and Selection ---
900
901 /// Returns the identifier of the currently active fork. Reverts if no fork is currently active.
902 #[cheatcode(group = Evm, safety = Unsafe)]
903 function activeFork() external view returns (uint256 forkId);
904
905 /// Creates a new fork with the given endpoint and the _latest_ block and returns the identifier of the fork.
906 #[cheatcode(group = Evm, safety = Unsafe)]
907 function createFork(string calldata urlOrAlias) external returns (uint256 forkId);
908 /// Creates a new fork with the given endpoint and block and returns the identifier of the fork.
909 #[cheatcode(group = Evm, safety = Unsafe)]
910 function createFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);
911 /// Creates a new fork with the given endpoint and at the block the given transaction was mined in,
912 /// replays all transaction mined in the block before the transaction, and returns the identifier of the fork.
913 #[cheatcode(group = Evm, safety = Unsafe)]
914 function createFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);
915
916 /// Creates and also selects a new fork with the given endpoint and the latest block and returns the identifier of the fork.
917 #[cheatcode(group = Evm, safety = Unsafe)]
918 function createSelectFork(string calldata urlOrAlias) external returns (uint256 forkId);
919 /// Creates and also selects a new fork with the given endpoint and block and returns the identifier of the fork.
920 #[cheatcode(group = Evm, safety = Unsafe)]
921 function createSelectFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);
922 /// Creates and also selects new fork with the given endpoint and at the block the given transaction was mined in,
923 /// replays all transaction mined in the block before the transaction, returns the identifier of the fork.
924 #[cheatcode(group = Evm, safety = Unsafe)]
925 function createSelectFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);
926
927 /// Updates the currently active fork to given block number
928 /// This is similar to `roll` but for the currently active fork.
929 #[cheatcode(group = Evm, safety = Unsafe)]
930 function rollFork(uint256 blockNumber) external;
931 /// Updates the currently active fork to given transaction. This will `rollFork` with the number
932 /// of the block the transaction was mined in and replays all transaction mined before it in the block.
933 #[cheatcode(group = Evm, safety = Unsafe)]
934 function rollFork(bytes32 txHash) external;
935 /// Updates the given fork to given block number.
936 #[cheatcode(group = Evm, safety = Unsafe)]
937 function rollFork(uint256 forkId, uint256 blockNumber) external;
938 /// Updates the given fork to block number of the given transaction and replays all transaction mined before it in the block.
939 #[cheatcode(group = Evm, safety = Unsafe)]
940 function rollFork(uint256 forkId, bytes32 txHash) external;
941
942 /// Takes a fork identifier created by `createFork` and sets the corresponding forked state as active.
943 #[cheatcode(group = Evm, safety = Unsafe)]
944 function selectFork(uint256 forkId) external;
945
946 /// Fetches the given transaction from the active fork and executes it on the current state.
947 #[cheatcode(group = Evm, safety = Unsafe)]
948 function transact(bytes32 txHash) external;
949 /// Fetches the given transaction from the given fork and executes it on the current state.
950 #[cheatcode(group = Evm, safety = Unsafe)]
951 function transact(uint256 forkId, bytes32 txHash) external;
952
953 /// Performs an Ethereum JSON-RPC request to the current fork URL.
954 #[cheatcode(group = Evm, safety = Safe)]
955 function rpc(string calldata method, string calldata params) external returns (bytes memory data);
956
957 /// Performs an Ethereum JSON-RPC request to the given endpoint.
958 #[cheatcode(group = Evm, safety = Safe)]
959 function rpc(string calldata urlOrAlias, string calldata method, string calldata params)
960 external
961 returns (bytes memory data);
962
963 /// Performs an Ethereum JSON-RPC request to the current fork URL and returns the JSON result.
964 #[cheatcode(group = Evm, safety = Safe)]
965 function rpcJson(string calldata method, string calldata params) external returns (string memory data);
966
967 /// Performs an Ethereum JSON-RPC request to the given endpoint and returns the JSON result.
968 #[cheatcode(group = Evm, safety = Safe)]
969 function rpcJson(string calldata urlOrAlias, string calldata method, string calldata params)
970 external
971 returns (string memory data);
972
973 /// Gets all the logs according to specified filter.
974 #[cheatcode(group = Evm, safety = Safe)]
975 function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] calldata topics)
976 external
977 view
978 returns (EthGetLogs[] memory logs);
979
980 // --- Behavior ---
981
982 /// In forking mode, explicitly grant the given address cheatcode access.
983 #[cheatcode(group = Evm, safety = Unsafe)]
984 function allowCheatcodes(address account) external;
985
986 /// Marks that the account(s) should use persistent storage across fork swaps in a multifork setup
987 /// Meaning, changes made to the state of this account will be kept when switching forks.
988 #[cheatcode(group = Evm, safety = Unsafe)]
989 function makePersistent(address account) external;
990 /// See `makePersistent(address)`.
991 #[cheatcode(group = Evm, safety = Unsafe)]
992 function makePersistent(address account0, address account1) external;
993 /// See `makePersistent(address)`.
994 #[cheatcode(group = Evm, safety = Unsafe)]
995 function makePersistent(address account0, address account1, address account2) external;
996 /// See `makePersistent(address)`.
997 #[cheatcode(group = Evm, safety = Unsafe)]
998 function makePersistent(address[] calldata accounts) external;
999
1000 /// Revokes persistent status from the address, previously added via `makePersistent`.
1001 #[cheatcode(group = Evm, safety = Unsafe)]
1002 function revokePersistent(address account) external;
1003 /// See `revokePersistent(address)`.
1004 #[cheatcode(group = Evm, safety = Unsafe)]
1005 function revokePersistent(address[] calldata accounts) external;
1006
1007 /// Returns true if the account is marked as persistent.
1008 #[cheatcode(group = Evm, safety = Unsafe)]
1009 function isPersistent(address account) external view returns (bool persistent);
1010
1011 // -------- Record Logs --------
1012
1013 /// Record all the transaction logs.
1014 #[cheatcode(group = Evm, safety = Safe)]
1015 function recordLogs() external;
1016
1017 /// Gets all the recorded logs.
1018 #[cheatcode(group = Evm, safety = Safe)]
1019 function getRecordedLogs() external view returns (Log[] memory logs);
1020
1021 /// Gets all the recorded logs, in JSON format.
1022 #[cheatcode(group = Evm, safety = Safe)]
1023 function getRecordedLogsJson() external view returns (string memory logsJson);
1024
1025 // -------- Gas Metering --------
1026
1027 // It's recommend to use the `noGasMetering` modifier included with forge-std, instead of
1028 // using these functions directly.
1029
1030 /// Pauses gas metering (i.e. gas usage is not counted). Noop if already paused.
1031 #[cheatcode(group = Evm, safety = Safe)]
1032 function pauseGasMetering() external;
1033
1034 /// Resumes gas metering (i.e. gas usage is counted again). Noop if already on.
1035 #[cheatcode(group = Evm, safety = Safe)]
1036 function resumeGasMetering() external;
1037
1038 /// Reset gas metering (i.e. gas usage is set to gas limit).
1039 #[cheatcode(group = Evm, safety = Safe)]
1040 function resetGasMetering() external;
1041
1042 // -------- Gas Measurement --------
1043
1044 /// DEPRECATED: use `lastFrameGas` instead.
1045 /// Gets the gas used in the last call from the callee perspective.
1046 #[cheatcode(group = Evm, safety = Safe, status = Deprecated(Some("replaced by `lastFrameGas`")))]
1047 function lastCallGas() external view returns (Gas memory gas);
1048
1049 /// Gets the gas used in the last call or create from the callee perspective.
1050 #[cheatcode(group = Evm, safety = Safe)]
1051 function lastFrameGas() external view returns (Gas memory gas);
1052
1053 // ======== Test Assertions and Utilities ========
1054
1055 /// If the condition is false, discard this run's fuzz inputs and generate new ones.
1056 #[cheatcode(group = Testing, safety = Safe)]
1057 function assume(bool condition) external pure;
1058
1059 /// Discard this run's fuzz inputs and generate new ones if next call reverted.
1060 #[cheatcode(group = Testing, safety = Safe)]
1061 function assumeNoRevert() external pure;
1062
1063 /// Discard this run's fuzz inputs and generate new ones if next call reverts with the potential revert parameters.
1064 #[cheatcode(group = Testing, safety = Safe)]
1065 function assumeNoRevert(PotentialRevert calldata potentialRevert) external pure;
1066
1067 /// Discard this run's fuzz inputs and generate new ones if next call reverts with the any of the potential revert parameters.
1068 #[cheatcode(group = Testing, safety = Safe)]
1069 function assumeNoRevert(PotentialRevert[] calldata potentialReverts) external pure;
1070
1071 /// Writes a breakpoint to jump to in the debugger.
1072 #[cheatcode(group = Testing, safety = Safe)]
1073 function breakpoint(string calldata char) external pure;
1074
1075 /// Writes a conditional breakpoint to jump to in the debugger.
1076 #[cheatcode(group = Testing, safety = Safe)]
1077 function breakpoint(string calldata char, bool value) external pure;
1078
1079 /// Returns the Foundry version.
1080 /// Format: <cargo_version>-<tag>+<git_sha_short>.<unix_build_timestamp>.<profile>
1081 /// Sample output: 0.3.0-nightly+3cb96bde9b.1737036656.debug
1082 /// Note: Build timestamps may vary slightly across platforms due to separate CI jobs.
1083 /// For reliable version comparisons, use UNIX format (e.g., >= 1700000000)
1084 /// to compare timestamps while ignoring minor time differences.
1085 #[cheatcode(group = Testing, safety = Safe)]
1086 function getFoundryVersion() external view returns (string memory version);
1087
1088 /// Returns the RPC url for the given alias.
1089 #[cheatcode(group = Testing, safety = Safe)]
1090 function rpcUrl(string calldata rpcAlias) external view returns (string memory json);
1091
1092 /// Returns all rpc urls and their aliases `[alias, url][]`.
1093 #[cheatcode(group = Testing, safety = Safe)]
1094 function rpcUrls() external view returns (string[2][] memory urls);
1095
1096 /// Returns all rpc urls and their aliases as structs.
1097 #[cheatcode(group = Testing, safety = Safe)]
1098 function rpcUrlStructs() external view returns (Rpc[] memory urls);
1099
1100 /// Returns a Chain struct for specific alias
1101 #[cheatcode(group = Testing, safety = Safe)]
1102 function getChain(string calldata chainAlias) external view returns (Chain memory chain);
1103
1104 /// Returns a Chain struct for specific chainId
1105 #[cheatcode(group = Testing, safety = Safe)]
1106 function getChain(uint256 chainId) external view returns (Chain memory chain);
1107
1108 /// Suspends execution of the main thread for `duration` milliseconds.
1109 #[cheatcode(group = Testing, safety = Safe)]
1110 function sleep(uint256 duration) external;
1111
1112 /// Expects a call to an address with the specified calldata.
1113 /// Calldata can either be a strict or a partial match.
1114 #[cheatcode(group = Testing, safety = Unsafe)]
1115 function expectCall(address callee, bytes calldata data) external;
1116
1117 /// Expects given number of calls to an address with the specified calldata.
1118 #[cheatcode(group = Testing, safety = Unsafe)]
1119 function expectCall(address callee, bytes calldata data, uint64 count) external;
1120
1121 /// Expects a call to an address with the specified `msg.value` and calldata.
1122 #[cheatcode(group = Testing, safety = Unsafe)]
1123 function expectCall(address callee, uint256 msgValue, bytes calldata data) external;
1124
1125 /// Expects given number of calls to an address with the specified `msg.value` and calldata.
1126 #[cheatcode(group = Testing, safety = Unsafe)]
1127 function expectCall(address callee, uint256 msgValue, bytes calldata data, uint64 count) external;
1128
1129 /// Expect a call to an address with the specified `msg.value`, gas, and calldata.
1130 #[cheatcode(group = Testing, safety = Unsafe)]
1131 function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data) external;
1132
1133 /// Expects given number of calls to an address with the specified `msg.value`, gas, and calldata.
1134 #[cheatcode(group = Testing, safety = Unsafe)]
1135 function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data, uint64 count) external;
1136
1137 /// Expect a call to an address with the specified `msg.value` and calldata, and a *minimum* amount of gas.
1138 #[cheatcode(group = Testing, safety = Unsafe)]
1139 function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data) external;
1140
1141 /// Expect given number of calls to an address with the specified `msg.value` and calldata, and a *minimum* amount of gas.
1142 #[cheatcode(group = Testing, safety = Unsafe)]
1143 function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data, uint64 count)
1144 external;
1145
1146 /// Prepare an expected log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.).
1147 /// Call this function, then emit an event, then call a function. Internally after the call, we check if
1148 /// logs were emitted in the expected order with the expected topics and data (as specified by the booleans).
1149 /// Must be placed immediately before the call you want to assert on. If the next call reverts and the
1150 /// revert is caught by the caller (low-level call or try/catch), the expectation remains active and may
1151 /// be satisfied by a log emitted from a later call.
1152 #[cheatcode(group = Testing, safety = Unsafe)]
1153 function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external;
1154
1155 /// Same as the previous method, but also checks supplied address against emitting contract.
1156 #[cheatcode(group = Testing, safety = Unsafe)]
1157 function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter)
1158 external;
1159
1160 /// Prepare an expected log with all topic and data checks enabled.
1161 /// Call this function, then emit an event, then call a function. Internally after the call, we check if
1162 /// logs were emitted in the expected order with the expected topics and data.
1163 /// Must be placed immediately before the call you want to assert on. If the next call reverts and the
1164 /// revert is caught by the caller (low-level call or try/catch), the expectation remains active and may
1165 /// be satisfied by a log emitted from a later call.
1166 #[cheatcode(group = Testing, safety = Unsafe)]
1167 function expectEmit() external;
1168
1169 /// Same as the previous method, but also checks supplied address against emitting contract.
1170 #[cheatcode(group = Testing, safety = Unsafe)]
1171 function expectEmit(address emitter) external;
1172
1173 /// Expect a given number of logs with the provided topics.
1174 #[cheatcode(group = Testing, safety = Unsafe)]
1175 function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, uint64 count) external;
1176
1177 /// Expect a given number of logs from a specific emitter with the provided topics.
1178 #[cheatcode(group = Testing, safety = Unsafe)]
1179 function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter, uint64 count)
1180 external;
1181
1182 /// Expect a given number of logs with all topic and data checks enabled.
1183 #[cheatcode(group = Testing, safety = Unsafe)]
1184 function expectEmit(uint64 count) external;
1185
1186 /// Expect a given number of logs from a specific emitter with all topic and data checks enabled.
1187 #[cheatcode(group = Testing, safety = Unsafe)]
1188 function expectEmit(address emitter, uint64 count) external;
1189
1190 /// Prepare an expected anonymous log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.).
1191 /// Call this function, then emit an anonymous event, then call a function. Internally after the call, we check if
1192 /// logs were emitted in the expected order with the expected topics and data (as specified by the booleans).
1193 #[cheatcode(group = Testing, safety = Unsafe)]
1194 function expectEmitAnonymous(bool checkTopic0, bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external;
1195
1196 /// Same as the previous method, but also checks supplied address against emitting contract.
1197 #[cheatcode(group = Testing, safety = Unsafe)]
1198 function expectEmitAnonymous(bool checkTopic0, bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter)
1199 external;
1200
1201 /// Prepare an expected anonymous log with all topic and data checks enabled.
1202 /// Call this function, then emit an anonymous event, then call a function. Internally after the call, we check if
1203 /// logs were emitted in the expected order with the expected topics and data.
1204 #[cheatcode(group = Testing, safety = Unsafe)]
1205 function expectEmitAnonymous() external;
1206
1207 /// Same as the previous method, but also checks supplied address against emitting contract.
1208 #[cheatcode(group = Testing, safety = Unsafe)]
1209 function expectEmitAnonymous(address emitter) external;
1210
1211 /// Expects the deployment of the specified bytecode by the specified address using the CREATE opcode
1212 #[cheatcode(group = Testing, safety = Unsafe)]
1213 function expectCreate(bytes calldata bytecode, address deployer) external;
1214
1215 /// Expects the deployment of the specified bytecode by the specified address using the CREATE2 opcode
1216 #[cheatcode(group = Testing, safety = Unsafe)]
1217 function expectCreate2(bytes calldata bytecode, address deployer) external;
1218
1219 /// Expects a TIP-20 `LogoURIUpdated(address indexed updater, string newLogoURI)` event.
1220 #[cheatcode(group = Testing, safety = Unsafe)]
1221 function expectTip20LogoURIUpdated(address token, address updater, string calldata newLogoURI) external;
1222
1223 /// Expects a call to `SignatureVerifier.verifyKeychain(account, digest, signature)`.
1224 #[cheatcode(group = Testing, safety = Unsafe)]
1225 function expectKeychainVerified(address account, bytes32 digest, bytes calldata signature) external;
1226
1227 /// Expects a call to `SignatureVerifier.verifyKeychainAdmin(account, digest, signature)`.
1228 ///
1229 /// The supplied `digest` should already be domain-separated with chain ID, contract address,
1230 /// and account address.
1231 #[cheatcode(group = Testing, safety = Unsafe)]
1232 function expectKeychainAdminVerified(address account, bytes32 digest, bytes calldata signature) external;
1233
1234 /// Expects a TIP-20 `LogoURIUpdated(address indexed updater, string newLogoURI)` event.
1235 #[cheatcode(group = Testing, safety = Unsafe)]
1236 function expectLogoURIUpdated(address token, address updater, string calldata newLogoURI) external;
1237
1238 /// Expects an error on next call with any revert data.
1239 #[cheatcode(group = Testing, safety = Unsafe)]
1240 function expectRevert() external;
1241
1242 /// Expects an error on next call that exactly matches the revert data.
1243 #[cheatcode(group = Testing, safety = Unsafe)]
1244 function expectRevert(bytes4 revertData) external;
1245
1246 /// Expects an error on next call that exactly matches the revert data.
1247 #[cheatcode(group = Testing, safety = Unsafe)]
1248 function expectRevert(bytes calldata revertData) external;
1249
1250 /// Expects an error with any revert data on next call to reverter address.
1251 ///
1252 /// The `reverter` argument is matched against the address associated with
1253 /// the frame that produced the revert:
1254 /// - For a CALL: the address that was called.
1255 /// - For a CREATE / CREATE2: the would-be deployed address of the failed
1256 /// deployment (computed from the deployer + nonce, or salt + initcode).
1257 ///
1258 /// For a single expected revert, the innermost reverting frame wins in
1259 /// nested CALL, CREATE, or mixed chains. With `count > 1`, nested
1260 /// CREATE / CREATE2 chains apply the same rule independently to each
1261 /// iteration; nested CALL chains keep their existing
1262 /// outermost-call-per-iteration behavior.
1263 #[cheatcode(group = Testing, safety = Unsafe)]
1264 function expectRevert(address reverter) external;
1265
1266 /// Expects an error from reverter address on next call, with any revert data.
1267 /// See `expectRevert(address)` for `reverter` matching semantics.
1268 #[cheatcode(group = Testing, safety = Unsafe)]
1269 function expectRevert(bytes4 revertData, address reverter) external;
1270
1271 /// Expects an error from reverter address on next call, that exactly matches the revert data.
1272 /// See `expectRevert(address)` for `reverter` matching semantics.
1273 #[cheatcode(group = Testing, safety = Unsafe)]
1274 function expectRevert(bytes calldata revertData, address reverter) external;
1275
1276 /// Expects a `count` number of reverts from the upcoming calls with any revert data or reverter.
1277 #[cheatcode(group = Testing, safety = Unsafe)]
1278 function expectRevert(uint64 count) external;
1279
1280 /// Expects a `count` number of reverts from the upcoming calls that match the revert data.
1281 #[cheatcode(group = Testing, safety = Unsafe)]
1282 function expectRevert(bytes4 revertData, uint64 count) external;
1283
1284 /// Expects a `count` number of reverts from the upcoming calls that exactly match the revert data.
1285 #[cheatcode(group = Testing, safety = Unsafe)]
1286 function expectRevert(bytes calldata revertData, uint64 count) external;
1287
1288 /// Expects a `count` number of reverts from the upcoming calls from the reverter address.
1289 /// See `expectRevert(address)` for `reverter` matching semantics.
1290 #[cheatcode(group = Testing, safety = Unsafe)]
1291 function expectRevert(address reverter, uint64 count) external;
1292
1293 /// Expects a `count` number of reverts from the upcoming calls from the reverter address that match the revert data.
1294 /// See `expectRevert(address)` for `reverter` matching semantics.
1295 #[cheatcode(group = Testing, safety = Unsafe)]
1296 function expectRevert(bytes4 revertData, address reverter, uint64 count) external;
1297
1298 /// Expects a `count` number of reverts from the upcoming calls from the reverter address that exactly match the revert data.
1299 /// See `expectRevert(address)` for `reverter` matching semantics.
1300 #[cheatcode(group = Testing, safety = Unsafe)]
1301 function expectRevert(bytes calldata revertData, address reverter, uint64 count) external;
1302
1303 /// Expects an error on next call that starts with the revert data.
1304 #[cheatcode(group = Testing, safety = Unsafe)]
1305 function expectPartialRevert(bytes4 revertData) external;
1306
1307 /// Expects an error on next call to reverter address, that starts with the revert data.
1308 /// See `expectRevert(address)` for `reverter` matching semantics.
1309 #[cheatcode(group = Testing, safety = Unsafe)]
1310 function expectPartialRevert(bytes4 revertData, address reverter) external;
1311
1312 /// Expects an error on next cheatcode call with any revert data.
1313 #[cheatcode(group = Testing, safety = Unsafe, status = Internal)]
1314 function _expectCheatcodeRevert() external;
1315
1316 /// Expects an error on next cheatcode call that starts with the revert data.
1317 #[cheatcode(group = Testing, safety = Unsafe, status = Internal)]
1318 function _expectCheatcodeRevert(bytes4 revertData) external;
1319
1320 /// Expects an error on next cheatcode call that exactly matches the revert data.
1321 #[cheatcode(group = Testing, safety = Unsafe, status = Internal)]
1322 function _expectCheatcodeRevert(bytes calldata revertData) external;
1323
1324 /// Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the current subcontext. If any other
1325 /// memory is written to, the test will fail. Can be called multiple times to add more ranges to the set.
1326 #[cheatcode(group = Testing, safety = Unsafe)]
1327 function expectSafeMemory(uint64 min, uint64 max) external;
1328
1329 /// Stops all safe memory expectation in the current subcontext.
1330 #[cheatcode(group = Testing, safety = Unsafe)]
1331 function stopExpectSafeMemory() external;
1332
1333 /// Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the next created subcontext.
1334 /// If any other memory is written to, the test will fail. Can be called multiple times to add more ranges
1335 /// to the set.
1336 #[cheatcode(group = Testing, safety = Unsafe)]
1337 function expectSafeMemoryCall(uint64 min, uint64 max) external;
1338
1339 /// Marks a test as skipped. Must be called at the top level of a test.
1340 #[cheatcode(group = Testing, safety = Unsafe)]
1341 function skip(bool skipTest) external;
1342
1343 /// Marks a test as skipped with a reason. Must be called at the top level of a test.
1344 #[cheatcode(group = Testing, safety = Unsafe)]
1345 function skip(bool skipTest, string calldata reason) external;
1346
1347 /// Asserts that the given condition is true.
1348 #[cheatcode(group = Testing, safety = Safe)]
1349 function assertTrue(bool condition) external pure;
1350
1351 /// Asserts that the given condition is true and includes error message into revert string on failure.
1352 #[cheatcode(group = Testing, safety = Safe)]
1353 function assertTrue(bool condition, string calldata err) external pure;
1354
1355 /// Asserts that the given condition is false.
1356 #[cheatcode(group = Testing, safety = Safe)]
1357 function assertFalse(bool condition) external pure;
1358
1359 /// Asserts that the given condition is false and includes error message into revert string on failure.
1360 #[cheatcode(group = Testing, safety = Safe)]
1361 function assertFalse(bool condition, string calldata err) external pure;
1362
1363 /// Asserts that two `bool` values are equal.
1364 #[cheatcode(group = Testing, safety = Safe)]
1365 function assertEq(bool left, bool right) external pure;
1366
1367 /// Asserts that two `bool` values are equal and includes error message into revert string on failure.
1368 #[cheatcode(group = Testing, safety = Safe)]
1369 function assertEq(bool left, bool right, string calldata err) external pure;
1370
1371 /// Asserts that two `uint256` values are equal.
1372 #[cheatcode(group = Testing, safety = Safe)]
1373 function assertEq(uint256 left, uint256 right) external pure;
1374
1375 /// Asserts that two `uint256` values are equal and includes error message into revert string on failure.
1376 #[cheatcode(group = Testing, safety = Safe)]
1377 function assertEq(uint256 left, uint256 right, string calldata err) external pure;
1378
1379 /// Asserts that two `int256` values are equal.
1380 #[cheatcode(group = Testing, safety = Safe)]
1381 function assertEq(int256 left, int256 right) external pure;
1382
1383 /// Asserts that two `int256` values are equal and includes error message into revert string on failure.
1384 #[cheatcode(group = Testing, safety = Safe)]
1385 function assertEq(int256 left, int256 right, string calldata err) external pure;
1386
1387 /// Asserts that two `address` values are equal.
1388 #[cheatcode(group = Testing, safety = Safe)]
1389 function assertEq(address left, address right) external pure;
1390
1391 /// Asserts that two `address` values are equal and includes error message into revert string on failure.
1392 #[cheatcode(group = Testing, safety = Safe)]
1393 function assertEq(address left, address right, string calldata err) external pure;
1394
1395 /// Asserts that two `bytes32` values are equal.
1396 #[cheatcode(group = Testing, safety = Safe)]
1397 function assertEq(bytes32 left, bytes32 right) external pure;
1398
1399 /// Asserts that two `bytes32` values are equal and includes error message into revert string on failure.
1400 #[cheatcode(group = Testing, safety = Safe)]
1401 function assertEq(bytes32 left, bytes32 right, string calldata err) external pure;
1402
1403 /// Asserts that two `string` values are equal.
1404 #[cheatcode(group = Testing, safety = Safe)]
1405 function assertEq(string calldata left, string calldata right) external pure;
1406
1407 /// Asserts that two `string` values are equal and includes error message into revert string on failure.
1408 #[cheatcode(group = Testing, safety = Safe)]
1409 function assertEq(string calldata left, string calldata right, string calldata err) external pure;
1410
1411 /// Asserts that two `bytes` values are equal.
1412 #[cheatcode(group = Testing, safety = Safe)]
1413 function assertEq(bytes calldata left, bytes calldata right) external pure;
1414
1415 /// Asserts that two `bytes` values are equal and includes error message into revert string on failure.
1416 #[cheatcode(group = Testing, safety = Safe)]
1417 function assertEq(bytes calldata left, bytes calldata right, string calldata err) external pure;
1418
1419 /// Asserts that two arrays of `bool` values are equal.
1420 #[cheatcode(group = Testing, safety = Safe)]
1421 function assertEq(bool[] calldata left, bool[] calldata right) external pure;
1422
1423 /// Asserts that two arrays of `bool` values are equal and includes error message into revert string on failure.
1424 #[cheatcode(group = Testing, safety = Safe)]
1425 function assertEq(bool[] calldata left, bool[] calldata right, string calldata err) external pure;
1426
1427 /// Asserts that two arrays of `uint256 values are equal.
1428 #[cheatcode(group = Testing, safety = Safe)]
1429 function assertEq(uint256[] calldata left, uint256[] calldata right) external pure;
1430
1431 /// Asserts that two arrays of `uint256` values are equal and includes error message into revert string on failure.
1432 #[cheatcode(group = Testing, safety = Safe)]
1433 function assertEq(uint256[] calldata left, uint256[] calldata right, string calldata err) external pure;
1434
1435 /// Asserts that two arrays of `int256` values are equal.
1436 #[cheatcode(group = Testing, safety = Safe)]
1437 function assertEq(int256[] calldata left, int256[] calldata right) external pure;
1438
1439 /// Asserts that two arrays of `int256` values are equal and includes error message into revert string on failure.
1440 #[cheatcode(group = Testing, safety = Safe)]
1441 function assertEq(int256[] calldata left, int256[] calldata right, string calldata err) external pure;
1442
1443 /// Asserts that two arrays of `address` values are equal.
1444 #[cheatcode(group = Testing, safety = Safe)]
1445 function assertEq(address[] calldata left, address[] calldata right) external pure;
1446
1447 /// Asserts that two arrays of `address` values are equal and includes error message into revert string on failure.
1448 #[cheatcode(group = Testing, safety = Safe)]
1449 function assertEq(address[] calldata left, address[] calldata right, string calldata err) external pure;
1450
1451 /// Asserts that two arrays of `bytes32` values are equal.
1452 #[cheatcode(group = Testing, safety = Safe)]
1453 function assertEq(bytes32[] calldata left, bytes32[] calldata right) external pure;
1454
1455 /// Asserts that two arrays of `bytes32` values are equal and includes error message into revert string on failure.
1456 #[cheatcode(group = Testing, safety = Safe)]
1457 function assertEq(bytes32[] calldata left, bytes32[] calldata right, string calldata err) external pure;
1458
1459 /// Asserts that two arrays of `string` values are equal.
1460 #[cheatcode(group = Testing, safety = Safe)]
1461 function assertEq(string[] calldata left, string[] calldata right) external pure;
1462
1463 /// Asserts that two arrays of `string` values are equal and includes error message into revert string on failure.
1464 #[cheatcode(group = Testing, safety = Safe)]
1465 function assertEq(string[] calldata left, string[] calldata right, string calldata err) external pure;
1466
1467 /// Asserts that two arrays of `bytes` values are equal.
1468 #[cheatcode(group = Testing, safety = Safe)]
1469 function assertEq(bytes[] calldata left, bytes[] calldata right) external pure;
1470
1471 /// Asserts that two arrays of `bytes` values are equal and includes error message into revert string on failure.
1472 #[cheatcode(group = Testing, safety = Safe)]
1473 function assertEq(bytes[] calldata left, bytes[] calldata right, string calldata err) external pure;
1474
1475 /// Asserts that two `uint256` values are equal, formatting them with decimals in failure message.
1476 #[cheatcode(group = Testing, safety = Safe)]
1477 function assertEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
1478
1479 /// Asserts that two `uint256` values are equal, formatting them with decimals in failure message.
1480 /// Includes error message into revert string on failure.
1481 #[cheatcode(group = Testing, safety = Safe)]
1482 function assertEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata err) external pure;
1483
1484 /// Asserts that two `int256` values are equal, formatting them with decimals in failure message.
1485 #[cheatcode(group = Testing, safety = Safe)]
1486 function assertEqDecimal(int256 left, int256 right, uint256 decimals) external pure;
1487
1488 /// Asserts that two `int256` values are equal, formatting them with decimals in failure message.
1489 /// Includes error message into revert string on failure.
1490 #[cheatcode(group = Testing, safety = Safe)]
1491 function assertEqDecimal(int256 left, int256 right, uint256 decimals, string calldata err) external pure;
1492
1493 /// Asserts that two `bool` values are not equal.
1494 #[cheatcode(group = Testing, safety = Safe)]
1495 function assertNotEq(bool left, bool right) external pure;
1496
1497 /// Asserts that two `bool` values are not equal and includes error message into revert string on failure.
1498 #[cheatcode(group = Testing, safety = Safe)]
1499 function assertNotEq(bool left, bool right, string calldata err) external pure;
1500
1501 /// Asserts that two `uint256` values are not equal.
1502 #[cheatcode(group = Testing, safety = Safe)]
1503 function assertNotEq(uint256 left, uint256 right) external pure;
1504
1505 /// Asserts that two `uint256` values are not equal and includes error message into revert string on failure.
1506 #[cheatcode(group = Testing, safety = Safe)]
1507 function assertNotEq(uint256 left, uint256 right, string calldata err) external pure;
1508
1509 /// Asserts that two `int256` values are not equal.
1510 #[cheatcode(group = Testing, safety = Safe)]
1511 function assertNotEq(int256 left, int256 right) external pure;
1512
1513 /// Asserts that two `int256` values are not equal and includes error message into revert string on failure.
1514 #[cheatcode(group = Testing, safety = Safe)]
1515 function assertNotEq(int256 left, int256 right, string calldata err) external pure;
1516
1517 /// Asserts that two `address` values are not equal.
1518 #[cheatcode(group = Testing, safety = Safe)]
1519 function assertNotEq(address left, address right) external pure;
1520
1521 /// Asserts that two `address` values are not equal and includes error message into revert string on failure.
1522 #[cheatcode(group = Testing, safety = Safe)]
1523 function assertNotEq(address left, address right, string calldata err) external pure;
1524
1525 /// Asserts that two `bytes32` values are not equal.
1526 #[cheatcode(group = Testing, safety = Safe)]
1527 function assertNotEq(bytes32 left, bytes32 right) external pure;
1528
1529 /// Asserts that two `bytes32` values are not equal and includes error message into revert string on failure.
1530 #[cheatcode(group = Testing, safety = Safe)]
1531 function assertNotEq(bytes32 left, bytes32 right, string calldata err) external pure;
1532
1533 /// Asserts that two `string` values are not equal.
1534 #[cheatcode(group = Testing, safety = Safe)]
1535 function assertNotEq(string calldata left, string calldata right) external pure;
1536
1537 /// Asserts that two `string` values are not equal and includes error message into revert string on failure.
1538 #[cheatcode(group = Testing, safety = Safe)]
1539 function assertNotEq(string calldata left, string calldata right, string calldata err) external pure;
1540
1541 /// Asserts that two `bytes` values are not equal.
1542 #[cheatcode(group = Testing, safety = Safe)]
1543 function assertNotEq(bytes calldata left, bytes calldata right) external pure;
1544
1545 /// Asserts that two `bytes` values are not equal and includes error message into revert string on failure.
1546 #[cheatcode(group = Testing, safety = Safe)]
1547 function assertNotEq(bytes calldata left, bytes calldata right, string calldata err) external pure;
1548
1549 /// Asserts that two arrays of `bool` values are not equal.
1550 #[cheatcode(group = Testing, safety = Safe)]
1551 function assertNotEq(bool[] calldata left, bool[] calldata right) external pure;
1552
1553 /// Asserts that two arrays of `bool` values are not equal and includes error message into revert string on failure.
1554 #[cheatcode(group = Testing, safety = Safe)]
1555 function assertNotEq(bool[] calldata left, bool[] calldata right, string calldata err) external pure;
1556
1557 /// Asserts that two arrays of `uint256` values are not equal.
1558 #[cheatcode(group = Testing, safety = Safe)]
1559 function assertNotEq(uint256[] calldata left, uint256[] calldata right) external pure;
1560
1561 /// Asserts that two arrays of `uint256` values are not equal and includes error message into revert string on failure.
1562 #[cheatcode(group = Testing, safety = Safe)]
1563 function assertNotEq(uint256[] calldata left, uint256[] calldata right, string calldata err) external pure;
1564
1565 /// Asserts that two arrays of `int256` values are not equal.
1566 #[cheatcode(group = Testing, safety = Safe)]
1567 function assertNotEq(int256[] calldata left, int256[] calldata right) external pure;
1568
1569 /// Asserts that two arrays of `int256` values are not equal and includes error message into revert string on failure.
1570 #[cheatcode(group = Testing, safety = Safe)]
1571 function assertNotEq(int256[] calldata left, int256[] calldata right, string calldata err) external pure;
1572
1573 /// Asserts that two arrays of `address` values are not equal.
1574 #[cheatcode(group = Testing, safety = Safe)]
1575 function assertNotEq(address[] calldata left, address[] calldata right) external pure;
1576
1577 /// Asserts that two arrays of `address` values are not equal and includes error message into revert string on failure.
1578 #[cheatcode(group = Testing, safety = Safe)]
1579 function assertNotEq(address[] calldata left, address[] calldata right, string calldata err) external pure;
1580
1581 /// Asserts that two arrays of `bytes32` values are not equal.
1582 #[cheatcode(group = Testing, safety = Safe)]
1583 function assertNotEq(bytes32[] calldata left, bytes32[] calldata right) external pure;
1584
1585 /// Asserts that two arrays of `bytes32` values are not equal and includes error message into revert string on failure.
1586 #[cheatcode(group = Testing, safety = Safe)]
1587 function assertNotEq(bytes32[] calldata left, bytes32[] calldata right, string calldata err) external pure;
1588
1589 /// Asserts that two arrays of `string` values are not equal.
1590 #[cheatcode(group = Testing, safety = Safe)]
1591 function assertNotEq(string[] calldata left, string[] calldata right) external pure;
1592
1593 /// Asserts that two arrays of `string` values are not equal and includes error message into revert string on failure.
1594 #[cheatcode(group = Testing, safety = Safe)]
1595 function assertNotEq(string[] calldata left, string[] calldata right, string calldata err) external pure;
1596
1597 /// Asserts that two arrays of `bytes` values are not equal.
1598 #[cheatcode(group = Testing, safety = Safe)]
1599 function assertNotEq(bytes[] calldata left, bytes[] calldata right) external pure;
1600
1601 /// Asserts that two arrays of `bytes` values are not equal and includes error message into revert string on failure.
1602 #[cheatcode(group = Testing, safety = Safe)]
1603 function assertNotEq(bytes[] calldata left, bytes[] calldata right, string calldata err) external pure;
1604
1605 /// Asserts that two `uint256` values are not equal, formatting them with decimals in failure message.
1606 #[cheatcode(group = Testing, safety = Safe)]
1607 function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
1608
1609 /// Asserts that two `uint256` values are not equal, formatting them with decimals in failure message.
1610 /// Includes error message into revert string on failure.
1611 #[cheatcode(group = Testing, safety = Safe)]
1612 function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata err) external pure;
1613
1614 /// Asserts that two `int256` values are not equal, formatting them with decimals in failure message.
1615 #[cheatcode(group = Testing, safety = Safe)]
1616 function assertNotEqDecimal(int256 left, int256 right, uint256 decimals) external pure;
1617
1618 /// Asserts that two `int256` values are not equal, formatting them with decimals in failure message.
1619 /// Includes error message into revert string on failure.
1620 #[cheatcode(group = Testing, safety = Safe)]
1621 function assertNotEqDecimal(int256 left, int256 right, uint256 decimals, string calldata err) external pure;
1622
1623 /// Compares two `uint256` values. Expects first value to be greater than second.
1624 #[cheatcode(group = Testing, safety = Safe)]
1625 function assertGt(uint256 left, uint256 right) external pure;
1626
1627 /// Compares two `uint256` values. Expects first value to be greater than second.
1628 /// Includes error message into revert string on failure.
1629 #[cheatcode(group = Testing, safety = Safe)]
1630 function assertGt(uint256 left, uint256 right, string calldata err) external pure;
1631
1632 /// Compares two `int256` values. Expects first value to be greater than second.
1633 #[cheatcode(group = Testing, safety = Safe)]
1634 function assertGt(int256 left, int256 right) external pure;
1635
1636 /// Compares two `int256` values. Expects first value to be greater than second.
1637 /// Includes error message into revert string on failure.
1638 #[cheatcode(group = Testing, safety = Safe)]
1639 function assertGt(int256 left, int256 right, string calldata err) external pure;
1640
1641 /// Compares two `uint256` values. Expects first value to be greater than second.
1642 /// Formats values with decimals in failure message.
1643 #[cheatcode(group = Testing, safety = Safe)]
1644 function assertGtDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
1645
1646 /// Compares two `uint256` values. Expects first value to be greater than second.
1647 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1648 #[cheatcode(group = Testing, safety = Safe)]
1649 function assertGtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata err) external pure;
1650
1651 /// Compares two `int256` values. Expects first value to be greater than second.
1652 /// Formats values with decimals in failure message.
1653 #[cheatcode(group = Testing, safety = Safe)]
1654 function assertGtDecimal(int256 left, int256 right, uint256 decimals) external pure;
1655
1656 /// Compares two `int256` values. Expects first value to be greater than second.
1657 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1658 #[cheatcode(group = Testing, safety = Safe)]
1659 function assertGtDecimal(int256 left, int256 right, uint256 decimals, string calldata err) external pure;
1660
1661 /// Compares two `uint256` values. Expects first value to be greater than or equal to second.
1662 #[cheatcode(group = Testing, safety = Safe)]
1663 function assertGe(uint256 left, uint256 right) external pure;
1664
1665 /// Compares two `uint256` values. Expects first value to be greater than or equal to second.
1666 /// Includes error message into revert string on failure.
1667 #[cheatcode(group = Testing, safety = Safe)]
1668 function assertGe(uint256 left, uint256 right, string calldata err) external pure;
1669
1670 /// Compares two `int256` values. Expects first value to be greater than or equal to second.
1671 #[cheatcode(group = Testing, safety = Safe)]
1672 function assertGe(int256 left, int256 right) external pure;
1673
1674 /// Compares two `int256` values. Expects first value to be greater than or equal to second.
1675 /// Includes error message into revert string on failure.
1676 #[cheatcode(group = Testing, safety = Safe)]
1677 function assertGe(int256 left, int256 right, string calldata err) external pure;
1678
1679 /// Compares two `uint256` values. Expects first value to be greater than or equal to second.
1680 /// Formats values with decimals in failure message.
1681 #[cheatcode(group = Testing, safety = Safe)]
1682 function assertGeDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
1683
1684 /// Compares two `uint256` values. Expects first value to be greater than or equal to second.
1685 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1686 #[cheatcode(group = Testing, safety = Safe)]
1687 function assertGeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata err) external pure;
1688
1689 /// Compares two `int256` values. Expects first value to be greater than or equal to second.
1690 /// Formats values with decimals in failure message.
1691 #[cheatcode(group = Testing, safety = Safe)]
1692 function assertGeDecimal(int256 left, int256 right, uint256 decimals) external pure;
1693
1694 /// Compares two `int256` values. Expects first value to be greater than or equal to second.
1695 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1696 #[cheatcode(group = Testing, safety = Safe)]
1697 function assertGeDecimal(int256 left, int256 right, uint256 decimals, string calldata err) external pure;
1698
1699 /// Compares two `uint256` values. Expects first value to be less than second.
1700 #[cheatcode(group = Testing, safety = Safe)]
1701 function assertLt(uint256 left, uint256 right) external pure;
1702
1703 /// Compares two `uint256` values. Expects first value to be less than second.
1704 /// Includes error message into revert string on failure.
1705 #[cheatcode(group = Testing, safety = Safe)]
1706 function assertLt(uint256 left, uint256 right, string calldata err) external pure;
1707
1708 /// Compares two `int256` values. Expects first value to be less than second.
1709 #[cheatcode(group = Testing, safety = Safe)]
1710 function assertLt(int256 left, int256 right) external pure;
1711
1712 /// Compares two `int256` values. Expects first value to be less than second.
1713 /// Includes error message into revert string on failure.
1714 #[cheatcode(group = Testing, safety = Safe)]
1715 function assertLt(int256 left, int256 right, string calldata err) external pure;
1716
1717 /// Compares two `uint256` values. Expects first value to be less than second.
1718 /// Formats values with decimals in failure message.
1719 #[cheatcode(group = Testing, safety = Safe)]
1720 function assertLtDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
1721
1722 /// Compares two `uint256` values. Expects first value to be less than second.
1723 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1724 #[cheatcode(group = Testing, safety = Safe)]
1725 function assertLtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata err) external pure;
1726
1727 /// Compares two `int256` values. Expects first value to be less than second.
1728 /// Formats values with decimals in failure message.
1729 #[cheatcode(group = Testing, safety = Safe)]
1730 function assertLtDecimal(int256 left, int256 right, uint256 decimals) external pure;
1731
1732 /// Compares two `int256` values. Expects first value to be less than second.
1733 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1734 #[cheatcode(group = Testing, safety = Safe)]
1735 function assertLtDecimal(int256 left, int256 right, uint256 decimals, string calldata err) external pure;
1736
1737 /// Compares two `uint256` values. Expects first value to be less than or equal to second.
1738 #[cheatcode(group = Testing, safety = Safe)]
1739 function assertLe(uint256 left, uint256 right) external pure;
1740
1741 /// Compares two `uint256` values. Expects first value to be less than or equal to second.
1742 /// Includes error message into revert string on failure.
1743 #[cheatcode(group = Testing, safety = Safe)]
1744 function assertLe(uint256 left, uint256 right, string calldata err) external pure;
1745
1746 /// Compares two `int256` values. Expects first value to be less than or equal to second.
1747 #[cheatcode(group = Testing, safety = Safe)]
1748 function assertLe(int256 left, int256 right) external pure;
1749
1750 /// Compares two `int256` values. Expects first value to be less than or equal to second.
1751 /// Includes error message into revert string on failure.
1752 #[cheatcode(group = Testing, safety = Safe)]
1753 function assertLe(int256 left, int256 right, string calldata err) external pure;
1754
1755 /// Compares two `uint256` values. Expects first value to be less than or equal to second.
1756 /// Formats values with decimals in failure message.
1757 #[cheatcode(group = Testing, safety = Safe)]
1758 function assertLeDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
1759
1760 /// Compares two `uint256` values. Expects first value to be less than or equal to second.
1761 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1762 #[cheatcode(group = Testing, safety = Safe)]
1763 function assertLeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata err) external pure;
1764
1765 /// Compares two `int256` values. Expects first value to be less than or equal to second.
1766 /// Formats values with decimals in failure message.
1767 #[cheatcode(group = Testing, safety = Safe)]
1768 function assertLeDecimal(int256 left, int256 right, uint256 decimals) external pure;
1769
1770 /// Compares two `int256` values. Expects first value to be less than or equal to second.
1771 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1772 #[cheatcode(group = Testing, safety = Safe)]
1773 function assertLeDecimal(int256 left, int256 right, uint256 decimals, string calldata err) external pure;
1774
1775 /// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`.
1776 #[cheatcode(group = Testing, safety = Safe)]
1777 function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta) external pure;
1778
1779 /// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`.
1780 /// Includes error message into revert string on failure.
1781 #[cheatcode(group = Testing, safety = Safe)]
1782 function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta, string calldata err) external pure;
1783
1784 /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`.
1785 #[cheatcode(group = Testing, safety = Safe)]
1786 function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta) external pure;
1787
1788 /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`.
1789 /// Includes error message into revert string on failure.
1790 #[cheatcode(group = Testing, safety = Safe)]
1791 function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta, string calldata err) external pure;
1792
1793 /// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`.
1794 /// Formats values with decimals in failure message.
1795 #[cheatcode(group = Testing, safety = Safe)]
1796 function assertApproxEqAbsDecimal(uint256 left, uint256 right, uint256 maxDelta, uint256 decimals) external pure;
1797
1798 /// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`.
1799 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1800 #[cheatcode(group = Testing, safety = Safe)]
1801 function assertApproxEqAbsDecimal(
1802 uint256 left,
1803 uint256 right,
1804 uint256 maxDelta,
1805 uint256 decimals,
1806 string calldata err
1807 ) external pure;
1808
1809 /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`.
1810 /// Formats values with decimals in failure message.
1811 #[cheatcode(group = Testing, safety = Safe)]
1812 function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals) external pure;
1813
1814 /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`.
1815 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1816 #[cheatcode(group = Testing, safety = Safe)]
1817 function assertApproxEqAbsDecimal(
1818 int256 left,
1819 int256 right,
1820 uint256 maxDelta,
1821 uint256 decimals,
1822 string calldata err
1823 ) external pure;
1824
1825 /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
1826 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
1827 #[cheatcode(group = Testing, safety = Safe)]
1828 function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta) external pure;
1829
1830 /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
1831 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
1832 /// Includes error message into revert string on failure.
1833 #[cheatcode(group = Testing, safety = Safe)]
1834 function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta, string calldata err) external pure;
1835
1836 /// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
1837 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
1838 #[cheatcode(group = Testing, safety = Safe)]
1839 function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta) external pure;
1840
1841 /// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
1842 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
1843 /// Includes error message into revert string on failure.
1844 #[cheatcode(group = Testing, safety = Safe)]
1845 function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta, string calldata err) external pure;
1846
1847 /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
1848 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
1849 /// Formats values with decimals in failure message.
1850 #[cheatcode(group = Testing, safety = Safe)]
1851 function assertApproxEqRelDecimal(
1852 uint256 left,
1853 uint256 right,
1854 uint256 maxPercentDelta,
1855 uint256 decimals
1856 ) external pure;
1857
1858 /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
1859 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
1860 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1861 #[cheatcode(group = Testing, safety = Safe)]
1862 function assertApproxEqRelDecimal(
1863 uint256 left,
1864 uint256 right,
1865 uint256 maxPercentDelta,
1866 uint256 decimals,
1867 string calldata err
1868 ) external pure;
1869
1870 /// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
1871 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
1872 /// Formats values with decimals in failure message.
1873 #[cheatcode(group = Testing, safety = Safe)]
1874 function assertApproxEqRelDecimal(
1875 int256 left,
1876 int256 right,
1877 uint256 maxPercentDelta,
1878 uint256 decimals
1879 ) external pure;
1880
1881 /// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
1882 /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
1883 /// Formats values with decimals in failure message. Includes error message into revert string on failure.
1884 #[cheatcode(group = Testing, safety = Safe)]
1885 function assertApproxEqRelDecimal(
1886 int256 left,
1887 int256 right,
1888 uint256 maxPercentDelta,
1889 uint256 decimals,
1890 string calldata err
1891 ) external pure;
1892
1893 /// Returns true if the current Foundry version is greater than or equal to the given version.
1894 /// The given version string must be in the format `major.minor.patch`.
1895 ///
1896 /// This is equivalent to `foundryVersionCmp(version) >= 0`.
1897 #[cheatcode(group = Testing, safety = Safe)]
1898 function foundryVersionAtLeast(string calldata version) external view returns (bool);
1899
1900 /// Compares the current Foundry version with the given version string.
1901 /// The given version string must be in the format `major.minor.patch`.
1902 ///
1903 /// Returns:
1904 /// -1 if current Foundry version is less than the given version
1905 /// 0 if current Foundry version equals the given version
1906 /// 1 if current Foundry version is greater than the given version
1907 ///
1908 /// This result can then be used with a comparison operator against `0`.
1909 /// For example, to check if the current Foundry version is greater than or equal to `1.0.0`:
1910 /// `if (foundryVersionCmp("1.0.0") >= 0) { ... }`
1911 #[cheatcode(group = Testing, safety = Safe)]
1912 function foundryVersionCmp(string calldata version) external view returns (int256);
1913
1914 // ======== OS and Filesystem ========
1915
1916 // -------- Metadata --------
1917
1918 /// Returns true if the given path points to an existing entity, else returns false.
1919 #[cheatcode(group = Filesystem)]
1920 function exists(string calldata path) external view returns (bool result);
1921
1922 /// Given a path, query the file system to get information about a file, directory, etc.
1923 #[cheatcode(group = Filesystem)]
1924 function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata);
1925
1926 /// Returns true if the path exists on disk and is pointing at a directory, else returns false.
1927 #[cheatcode(group = Filesystem)]
1928 function isDir(string calldata path) external view returns (bool result);
1929
1930 /// Returns true if the path exists on disk and is pointing at a regular file, else returns false.
1931 #[cheatcode(group = Filesystem)]
1932 function isFile(string calldata path) external view returns (bool result);
1933
1934 /// Get the path of the current project root.
1935 #[cheatcode(group = Filesystem)]
1936 function projectRoot() external view returns (string memory path);
1937
1938 /// Get the source file path of the currently running test or script contract,
1939 /// relative to the project root.
1940 #[cheatcode(group = Filesystem)]
1941 function currentFilePath() external view returns (string memory path);
1942
1943 /// Returns the time since unix epoch in milliseconds.
1944 #[cheatcode(group = Filesystem)]
1945 function unixTime() external view returns (uint256 milliseconds);
1946
1947 // -------- Reading and writing --------
1948
1949 /// Closes file for reading, resetting the offset and allowing to read it from beginning with readLine.
1950 /// `path` is relative to the project root.
1951 #[cheatcode(group = Filesystem)]
1952 function closeFile(string calldata path) external;
1953
1954 /// Copies the contents of one file to another. This function will **overwrite** the contents of `to`.
1955 /// On success, the total number of bytes copied is returned and it is equal to the length of the `to` file as reported by `metadata`.
1956 /// Both `from` and `to` are relative to the project root.
1957 #[cheatcode(group = Filesystem)]
1958 function copyFile(string calldata from, string calldata to) external returns (uint64 copied);
1959
1960 /// Creates a new, empty directory at the provided path.
1961 /// This cheatcode will revert in the following situations, but is not limited to just these cases:
1962 /// - User lacks permissions to modify `path`.
1963 /// - A parent of the given path doesn't exist and `recursive` is false.
1964 /// - `path` already exists and `recursive` is false.
1965 /// `path` is relative to the project root.
1966 #[cheatcode(group = Filesystem)]
1967 function createDir(string calldata path, bool recursive) external;
1968
1969 /// Reads the directory at the given path recursively, up to `maxDepth`.
1970 /// `maxDepth` defaults to 1, meaning only the direct children of the given directory will be returned.
1971 /// Follows symbolic links if `followLinks` is true.
1972 #[cheatcode(group = Filesystem)]
1973 function readDir(string calldata path) external view returns (DirEntry[] memory entries);
1974 /// See `readDir(string)`.
1975 #[cheatcode(group = Filesystem)]
1976 function readDir(string calldata path, uint64 maxDepth) external view returns (DirEntry[] memory entries);
1977 /// See `readDir(string)`.
1978 #[cheatcode(group = Filesystem)]
1979 function readDir(string calldata path, uint64 maxDepth, bool followLinks)
1980 external
1981 view
1982 returns (DirEntry[] memory entries);
1983
1984 /// Reads the entire content of file to string. `path` is relative to the project root.
1985 #[cheatcode(group = Filesystem)]
1986 function readFile(string calldata path) external view returns (string memory data);
1987
1988 /// Reads the entire content of file as binary. `path` is relative to the project root.
1989 #[cheatcode(group = Filesystem)]
1990 function readFileBinary(string calldata path) external view returns (bytes memory data);
1991
1992 /// Reads next line of file to string.
1993 #[cheatcode(group = Filesystem)]
1994 function readLine(string calldata path) external view returns (string memory line);
1995
1996 /// Reads a symbolic link, returning the path that the link points to.
1997 /// This cheatcode will revert in the following situations, but is not limited to just these cases:
1998 /// - `path` is not a symbolic link.
1999 /// - `path` does not exist.
2000 #[cheatcode(group = Filesystem)]
2001 function readLink(string calldata linkPath) external view returns (string memory targetPath);
2002
2003 /// Removes a directory at the provided path.
2004 /// This cheatcode will revert in the following situations, but is not limited to just these cases:
2005 /// - `path` doesn't exist.
2006 /// - `path` isn't a directory.
2007 /// - User lacks permissions to modify `path`.
2008 /// - The directory is not empty and `recursive` is false.
2009 /// `path` is relative to the project root.
2010 #[cheatcode(group = Filesystem)]
2011 function removeDir(string calldata path, bool recursive) external;
2012
2013 /// Removes a file from the filesystem.
2014 /// This cheatcode will revert in the following situations, but is not limited to just these cases:
2015 /// - `path` points to a directory.
2016 /// - The file doesn't exist.
2017 /// - The user lacks permissions to remove the file.
2018 /// `path` is relative to the project root.
2019 #[cheatcode(group = Filesystem)]
2020 function removeFile(string calldata path) external;
2021
2022 /// Writes data to file, creating a file if it does not exist, and entirely replacing its contents if it does.
2023 /// `path` is relative to the project root.
2024 #[cheatcode(group = Filesystem)]
2025 function writeFile(string calldata path, string calldata data) external;
2026
2027 /// Writes binary data to a file, creating a file if it does not exist, and entirely replacing its contents if it does.
2028 /// `path` is relative to the project root.
2029 #[cheatcode(group = Filesystem)]
2030 function writeFileBinary(string calldata path, bytes calldata data) external;
2031
2032 /// Writes line to file, creating a file if it does not exist.
2033 /// `path` is relative to the project root.
2034 #[cheatcode(group = Filesystem)]
2035 function writeLine(string calldata path, string calldata data) external;
2036
2037 /// Gets the artifact path from code (aka. creation code).
2038 #[cheatcode(group = Filesystem)]
2039 function getArtifactPathByCode(bytes calldata code) external view returns (string memory path);
2040
2041 /// Gets the artifact path from deployed code (aka. runtime code).
2042 #[cheatcode(group = Filesystem)]
2043 function getArtifactPathByDeployedCode(bytes calldata deployedCode) external view returns (string memory path);
2044
2045 /// Gets the creation bytecode from an artifact file. Takes in the relative path to the json file or the path to the
2046 /// artifact in the form of <path>:<contract>:<version> or <path>:<contract>:<profile> where <contract> and
2047 /// <version>/<profile> parts are optional. Use <profile> to select artifacts compiled with a specific profile
2048 /// from foundry.toml.
2049 #[cheatcode(group = Filesystem)]
2050 function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode);
2051
2052 /// Gets all function selectors from a contract artifact. Takes in the relative path to the json file or the path to the
2053 /// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
2054 #[cheatcode(group = Filesystem)]
2055 function getSelectors(string calldata artifactPath) external view returns (bytes4[] memory selectors);
2056
2057 /// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
2058 /// artifact in the form of <path>:<contract>:<version> or <path>:<contract>:<profile> where <contract> and
2059 /// <version>/<profile> parts are optional.
2060 /// Reverts if the target artifact contains unlinked library placeholders.
2061 #[cheatcode(group = Filesystem)]
2062 function deployCode(string calldata artifactPath) external returns (address deployedAddress);
2063
2064 /// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
2065 /// artifact in the form of <path>:<contract>:<version> or <path>:<contract>:<profile> where <contract> and
2066 /// <version>/<profile> parts are optional.
2067 /// Reverts if the target artifact contains unlinked library placeholders.
2068 ///
2069 /// Additionally accepts abi-encoded constructor arguments.
2070 #[cheatcode(group = Filesystem)]
2071 function deployCode(string calldata artifactPath, bytes calldata constructorArgs) external returns (address deployedAddress);
2072
2073 /// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
2074 /// artifact in the form of <path>:<contract>:<version> or <path>:<contract>:<profile> where <contract> and
2075 /// <version>/<profile> parts are optional.
2076 /// Reverts if the target artifact contains unlinked library placeholders.
2077 ///
2078 /// Additionally accepts `msg.value`.
2079 #[cheatcode(group = Filesystem)]
2080 function deployCode(string calldata artifactPath, uint256 value) external returns (address deployedAddress);
2081
2082 /// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
2083 /// artifact in the form of <path>:<contract>:<version> or <path>:<contract>:<profile> where <contract> and
2084 /// <version>/<profile> parts are optional.
2085 /// Reverts if the target artifact contains unlinked library placeholders.
2086 ///
2087 /// Additionally accepts abi-encoded constructor arguments and `msg.value`.
2088 #[cheatcode(group = Filesystem)]
2089 function deployCode(string calldata artifactPath, bytes calldata constructorArgs, uint256 value) external returns (address deployedAddress);
2090
2091 /// Deploys a contract from an artifact file, using the CREATE2 salt. Takes in the relative path to the json file or the path to the
2092 /// artifact in the form of <path>:<contract>:<version> or <path>:<contract>:<profile> where <contract> and
2093 /// <version>/<profile> parts are optional.
2094 /// Reverts if the target artifact contains unlinked library placeholders.
2095 #[cheatcode(group = Filesystem)]
2096 function deployCode(string calldata artifactPath, bytes32 salt) external returns (address deployedAddress);
2097
2098 /// Deploys a contract from an artifact file, using the CREATE2 salt. Takes in the relative path to the json file or the path to the
2099 /// artifact in the form of <path>:<contract>:<version> or <path>:<contract>:<profile> where <contract> and
2100 /// <version>/<profile> parts are optional.
2101 /// Reverts if the target artifact contains unlinked library placeholders.
2102 ///
2103 /// Additionally accepts abi-encoded constructor arguments.
2104 #[cheatcode(group = Filesystem)]
2105 function deployCode(string calldata artifactPath, bytes calldata constructorArgs, bytes32 salt) external returns (address deployedAddress);
2106
2107 /// Deploys a contract from an artifact file, using the CREATE2 salt. Takes in the relative path to the json file or the path to the
2108 /// artifact in the form of <path>:<contract>:<version> or <path>:<contract>:<profile> where <contract> and
2109 /// <version>/<profile> parts are optional.
2110 /// Reverts if the target artifact contains unlinked library placeholders.
2111 ///
2112 /// Additionally accepts `msg.value`.
2113 #[cheatcode(group = Filesystem)]
2114 function deployCode(string calldata artifactPath, uint256 value, bytes32 salt) external returns (address deployedAddress);
2115
2116 /// Deploys a contract from an artifact file, using the CREATE2 salt. Takes in the relative path to the json file or the path to the
2117 /// artifact in the form of <path>:<contract>:<version> or <path>:<contract>:<profile> where <contract> and
2118 /// <version>/<profile> parts are optional.
2119 /// Reverts if the target artifact contains unlinked library placeholders.
2120 ///
2121 /// Additionally accepts abi-encoded constructor arguments and `msg.value`.
2122 #[cheatcode(group = Filesystem)]
2123 function deployCode(string calldata artifactPath, bytes calldata constructorArgs, uint256 value, bytes32 salt) external returns (address deployedAddress);
2124
2125 /// Gets the deployed bytecode from an artifact file. Takes in the relative path to the json file or the path to the
2126 /// artifact in the form of <path>:<contract>:<version> or <path>:<contract>:<profile> where <contract> and
2127 /// <version>/<profile> parts are optional.
2128 #[cheatcode(group = Filesystem)]
2129 function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode);
2130
2131 /// Returns the most recent broadcast for the given contract on `chainId` matching `txType`.
2132 ///
2133 /// For example:
2134 ///
2135 /// The most recent deployment can be fetched by passing `txType` as `CREATE` or `CREATE2`.
2136 ///
2137 /// The most recent call can be fetched by passing `txType` as `CALL`.
2138 #[cheatcode(group = Filesystem)]
2139 function getBroadcast(string calldata contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary memory);
2140
2141 /// Returns all broadcasts for the given contract on `chainId` with the specified `txType`.
2142 ///
2143 /// Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.
2144 #[cheatcode(group = Filesystem)]
2145 function getBroadcasts(string calldata contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary[] memory);
2146
2147 /// Returns all broadcasts for the given contract on `chainId`.
2148 ///
2149 /// Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.
2150 #[cheatcode(group = Filesystem)]
2151 function getBroadcasts(string calldata contractName, uint64 chainId) external view returns (BroadcastTxSummary[] memory);
2152
2153 /// Returns the most recent deployment for the current `chainId`.
2154 #[cheatcode(group = Filesystem)]
2155 function getDeployment(string calldata contractName) external view returns (address deployedAddress);
2156
2157 /// Returns the most recent deployment for the given contract on `chainId`
2158 #[cheatcode(group = Filesystem)]
2159 function getDeployment(string calldata contractName, uint64 chainId) external view returns (address deployedAddress);
2160
2161 /// Returns all deployments for the given contract on `chainId`
2162 ///
2163 /// Sorted in descending order of deployment time i.e descending order of BroadcastTxSummary.blockNumber.
2164 ///
2165 /// The most recent deployment is the first element, and the oldest is the last.
2166 #[cheatcode(group = Filesystem)]
2167 function getDeployments(string calldata contractName, uint64 chainId) external view returns (address[] memory deployedAddresses);
2168
2169 // -------- Foreign Function Interface --------
2170
2171 /// Performs a foreign function call via the terminal.
2172 #[cheatcode(group = Filesystem)]
2173 function ffi(string[] calldata commandInput) external returns (bytes memory result);
2174
2175 /// Performs a foreign function call via terminal and returns the exit code, stdout, and stderr.
2176 #[cheatcode(group = Filesystem)]
2177 function tryFfi(string[] calldata commandInput) external returns (FfiResult memory result);
2178
2179 // -------- User Interaction --------
2180
2181 /// Prompts the user for a string value in the terminal.
2182 #[cheatcode(group = Filesystem)]
2183 function prompt(string calldata promptText) external returns (string memory input);
2184
2185 /// Prompts the user for a hidden string value in the terminal.
2186 #[cheatcode(group = Filesystem)]
2187 function promptSecret(string calldata promptText) external returns (string memory input);
2188
2189 /// Prompts the user for hidden uint256 in the terminal (usually pk).
2190 #[cheatcode(group = Filesystem)]
2191 function promptSecretUint(string calldata promptText) external returns (uint256);
2192
2193 /// Prompts the user for an address in the terminal.
2194 #[cheatcode(group = Filesystem)]
2195 function promptAddress(string calldata promptText) external returns (address);
2196
2197 /// Prompts the user for uint256 in the terminal.
2198 #[cheatcode(group = Filesystem)]
2199 function promptUint(string calldata promptText) external returns (uint256);
2200
2201 // ======== Environment Variables ========
2202
2203 /// Resolves the env variable placeholders of a given input string.
2204 #[cheatcode(group = Environment)]
2205 function resolveEnv(string calldata input) external returns (string memory);
2206
2207 /// Sets environment variables.
2208 #[cheatcode(group = Environment)]
2209 function setEnv(string calldata name, string calldata value) external;
2210
2211 /// Gets the environment variable `name` and returns true if it exists, else returns false.
2212 #[cheatcode(group = Environment)]
2213 function envExists(string calldata name) external view returns (bool result);
2214
2215 /// Gets the environment variable `name` and parses it as `bool`.
2216 /// Reverts if the variable was not found or could not be parsed.
2217 #[cheatcode(group = Environment)]
2218 function envBool(string calldata name) external view returns (bool value);
2219 /// Gets the environment variable `name` and parses it as `uint256`.
2220 /// Reverts if the variable was not found or could not be parsed.
2221 #[cheatcode(group = Environment)]
2222 function envUint(string calldata name) external view returns (uint256 value);
2223 /// Gets the environment variable `name` and parses it as `int256`.
2224 /// Reverts if the variable was not found or could not be parsed.
2225 #[cheatcode(group = Environment)]
2226 function envInt(string calldata name) external view returns (int256 value);
2227 /// Gets the environment variable `name` and parses it as `address`.
2228 /// Reverts if the variable was not found or could not be parsed.
2229 #[cheatcode(group = Environment)]
2230 function envAddress(string calldata name) external view returns (address value);
2231 /// Gets the environment variable `name` and parses it as `bytes32`.
2232 /// Reverts if the variable was not found or could not be parsed.
2233 #[cheatcode(group = Environment)]
2234 function envBytes32(string calldata name) external view returns (bytes32 value);
2235 /// Gets the environment variable `name` and parses it as `string`.
2236 /// Reverts if the variable was not found or could not be parsed.
2237 #[cheatcode(group = Environment)]
2238 function envString(string calldata name) external view returns (string memory value);
2239 /// Gets the environment variable `name` and parses it as `bytes`.
2240 /// Reverts if the variable was not found or could not be parsed.
2241 #[cheatcode(group = Environment)]
2242 function envBytes(string calldata name) external view returns (bytes memory value);
2243
2244 /// Gets the environment variable `name` and parses it as an array of `bool`, delimited by `delim`.
2245 /// Reverts if the variable was not found or could not be parsed.
2246 #[cheatcode(group = Environment)]
2247 function envBool(string calldata name, string calldata delim) external view returns (bool[] memory value);
2248 /// Gets the environment variable `name` and parses it as an array of `uint256`, delimited by `delim`.
2249 /// Reverts if the variable was not found or could not be parsed.
2250 #[cheatcode(group = Environment)]
2251 function envUint(string calldata name, string calldata delim) external view returns (uint256[] memory value);
2252 /// Gets the environment variable `name` and parses it as an array of `int256`, delimited by `delim`.
2253 /// Reverts if the variable was not found or could not be parsed.
2254 #[cheatcode(group = Environment)]
2255 function envInt(string calldata name, string calldata delim) external view returns (int256[] memory value);
2256 /// Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`.
2257 /// Reverts if the variable was not found or could not be parsed.
2258 #[cheatcode(group = Environment)]
2259 function envAddress(string calldata name, string calldata delim) external view returns (address[] memory value);
2260 /// Gets the environment variable `name` and parses it as an array of `bytes32`, delimited by `delim`.
2261 /// Reverts if the variable was not found or could not be parsed.
2262 #[cheatcode(group = Environment)]
2263 function envBytes32(string calldata name, string calldata delim) external view returns (bytes32[] memory value);
2264 /// Gets the environment variable `name` and parses it as an array of `string`, delimited by `delim`.
2265 /// Reverts if the variable was not found or could not be parsed.
2266 #[cheatcode(group = Environment)]
2267 function envString(string calldata name, string calldata delim) external view returns (string[] memory value);
2268 /// Gets the environment variable `name` and parses it as an array of `bytes`, delimited by `delim`.
2269 /// Reverts if the variable was not found or could not be parsed.
2270 #[cheatcode(group = Environment)]
2271 function envBytes(string calldata name, string calldata delim) external view returns (bytes[] memory value);
2272
2273 /// Gets the environment variable `name` and parses it as `bool`.
2274 /// Reverts if the variable could not be parsed.
2275 /// Returns `defaultValue` if the variable was not found.
2276 #[cheatcode(group = Environment)]
2277 function envOr(string calldata name, bool defaultValue) external view returns (bool value);
2278 /// Gets the environment variable `name` and parses it as `uint256`.
2279 /// Reverts if the variable could not be parsed.
2280 /// Returns `defaultValue` if the variable was not found.
2281 #[cheatcode(group = Environment)]
2282 function envOr(string calldata name, uint256 defaultValue) external view returns (uint256 value);
2283 /// Gets the environment variable `name` and parses it as `int256`.
2284 /// Reverts if the variable could not be parsed.
2285 /// Returns `defaultValue` if the variable was not found.
2286 #[cheatcode(group = Environment)]
2287 function envOr(string calldata name, int256 defaultValue) external view returns (int256 value);
2288 /// Gets the environment variable `name` and parses it as `address`.
2289 /// Reverts if the variable could not be parsed.
2290 /// Returns `defaultValue` if the variable was not found.
2291 #[cheatcode(group = Environment)]
2292 function envOr(string calldata name, address defaultValue) external view returns (address value);
2293 /// Gets the environment variable `name` and parses it as `bytes32`.
2294 /// Reverts if the variable could not be parsed.
2295 /// Returns `defaultValue` if the variable was not found.
2296 #[cheatcode(group = Environment)]
2297 function envOr(string calldata name, bytes32 defaultValue) external view returns (bytes32 value);
2298 /// Gets the environment variable `name` and parses it as `string`.
2299 /// Reverts if the variable could not be parsed.
2300 /// Returns `defaultValue` if the variable was not found.
2301 #[cheatcode(group = Environment)]
2302 function envOr(string calldata name, string calldata defaultValue) external view returns (string memory value);
2303 /// Gets the environment variable `name` and parses it as `bytes`.
2304 /// Reverts if the variable could not be parsed.
2305 /// Returns `defaultValue` if the variable was not found.
2306 #[cheatcode(group = Environment)]
2307 function envOr(string calldata name, bytes calldata defaultValue) external view returns (bytes memory value);
2308
2309 /// Gets the environment variable `name` and parses it as an array of `bool`, delimited by `delim`.
2310 /// Reverts if the variable could not be parsed.
2311 /// Returns `defaultValue` if the variable was not found.
2312 #[cheatcode(group = Environment)]
2313 function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue)
2314 external view
2315 returns (bool[] memory value);
2316 /// Gets the environment variable `name` and parses it as an array of `uint256`, delimited by `delim`.
2317 /// Reverts if the variable could not be parsed.
2318 /// Returns `defaultValue` if the variable was not found.
2319 #[cheatcode(group = Environment)]
2320 function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue)
2321 external view
2322 returns (uint256[] memory value);
2323 /// Gets the environment variable `name` and parses it as an array of `int256`, delimited by `delim`.
2324 /// Reverts if the variable could not be parsed.
2325 /// Returns `defaultValue` if the variable was not found.
2326 #[cheatcode(group = Environment)]
2327 function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue)
2328 external view
2329 returns (int256[] memory value);
2330 /// Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`.
2331 /// Reverts if the variable could not be parsed.
2332 /// Returns `defaultValue` if the variable was not found.
2333 #[cheatcode(group = Environment)]
2334 function envOr(string calldata name, string calldata delim, address[] calldata defaultValue)
2335 external view
2336 returns (address[] memory value);
2337 /// Gets the environment variable `name` and parses it as an array of `bytes32`, delimited by `delim`.
2338 /// Reverts if the variable could not be parsed.
2339 /// Returns `defaultValue` if the variable was not found.
2340 #[cheatcode(group = Environment)]
2341 function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue)
2342 external view
2343 returns (bytes32[] memory value);
2344 /// Gets the environment variable `name` and parses it as an array of `string`, delimited by `delim`.
2345 /// Reverts if the variable could not be parsed.
2346 /// Returns `defaultValue` if the variable was not found.
2347 #[cheatcode(group = Environment)]
2348 function envOr(string calldata name, string calldata delim, string[] calldata defaultValue)
2349 external view
2350 returns (string[] memory value);
2351 /// Gets the environment variable `name` and parses it as an array of `bytes`, delimited by `delim`.
2352 /// Reverts if the variable could not be parsed.
2353 /// Returns `defaultValue` if the variable was not found.
2354 #[cheatcode(group = Environment)]
2355 function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue)
2356 external view
2357 returns (bytes[] memory value);
2358
2359 /// Returns true if `forge` command was executed in given context.
2360 #[cheatcode(group = Environment)]
2361 function isContext(ForgeContext context) external view returns (bool result);
2362
2363 // ======== Scripts ========
2364 // -------- Broadcasting Transactions --------
2365
2366 /// Has the next call (at this call depth only) create transactions that can later be signed and sent onchain.
2367 ///
2368 /// Broadcasting address is determined by checking the following in order:
2369 /// 1. If `--sender` argument was provided, that address is used.
2370 /// 2. If exactly one signer (e.g. private key, hw wallet, keystore) is set when `forge broadcast` is invoked, that signer is used.
2371 /// 3. Otherwise, default foundry sender (1804c8AB1F12E6bbf3894d4083f33e07309d1f38) is used.
2372 #[cheatcode(group = Scripting)]
2373 function broadcast() external;
2374
2375 /// Has the next call (at this call depth only) create a transaction with the address provided
2376 /// as the sender that can later be signed and sent onchain.
2377 #[cheatcode(group = Scripting)]
2378 function broadcast(address signer) external;
2379
2380 /// Has the next call (at this call depth only) create a transaction with the private key
2381 /// provided as the sender that can later be signed and sent onchain.
2382 #[cheatcode(group = Scripting)]
2383 function broadcast(uint256 privateKey) external;
2384
2385 /// Has all subsequent calls (at this call depth only) create transactions that can later be signed and sent onchain.
2386 ///
2387 /// Broadcasting address is determined by checking the following in order:
2388 /// 1. If `--sender` argument was provided, that address is used.
2389 /// 2. If exactly one signer (e.g. private key, hw wallet, keystore) is set when `forge broadcast` is invoked, that signer is used.
2390 /// 3. Otherwise, default foundry sender (1804c8AB1F12E6bbf3894d4083f33e07309d1f38) is used.
2391 #[cheatcode(group = Scripting)]
2392 function startBroadcast() external;
2393
2394 /// Has all subsequent calls (at this call depth only) create transactions with the address
2395 /// provided that can later be signed and sent onchain.
2396 #[cheatcode(group = Scripting)]
2397 function startBroadcast(address signer) external;
2398
2399 /// Has all subsequent calls (at this call depth only) create transactions with the private key
2400 /// provided that can later be signed and sent onchain.
2401 #[cheatcode(group = Scripting)]
2402 function startBroadcast(uint256 privateKey) external;
2403
2404 /// Stops collecting onchain transactions.
2405 #[cheatcode(group = Scripting)]
2406 function stopBroadcast() external;
2407
2408 /// Takes a signed transaction and broadcasts it to the network.
2409 #[cheatcode(group = Scripting)]
2410 function broadcastRawTransaction(bytes calldata data) external;
2411
2412 /// Sign an EIP-7702 authorization for delegation
2413 #[cheatcode(group = Scripting)]
2414 function signDelegation(address implementation, uint256 privateKey) external returns (SignedDelegation memory signedDelegation);
2415
2416 /// Sign an EIP-7702 authorization for delegation for specific nonce
2417 #[cheatcode(group = Scripting)]
2418 function signDelegation(address implementation, uint256 privateKey, uint64 nonce) external returns (SignedDelegation memory signedDelegation);
2419
2420 /// Sign an EIP-7702 authorization for delegation, with optional cross-chain validity.
2421 #[cheatcode(group = Scripting)]
2422 function signDelegation(address implementation, uint256 privateKey, bool crossChain) external returns (SignedDelegation memory signedDelegation);
2423
2424 /// Designate the next call as an EIP-7702 transaction
2425 #[cheatcode(group = Scripting)]
2426 function attachDelegation(SignedDelegation calldata signedDelegation) external;
2427
2428 /// Designate the next call as an EIP-7702 transaction, with optional cross-chain validity.
2429 #[cheatcode(group = Scripting)]
2430 function attachDelegation(SignedDelegation calldata signedDelegation, bool crossChain) external;
2431
2432 /// Sign an EIP-7702 authorization and designate the next call as an EIP-7702 transaction
2433 #[cheatcode(group = Scripting)]
2434 function signAndAttachDelegation(address implementation, uint256 privateKey) external returns (SignedDelegation memory signedDelegation);
2435
2436 /// Sign an EIP-7702 authorization and designate the next call as an EIP-7702 transaction for specific nonce
2437 #[cheatcode(group = Scripting)]
2438 function signAndAttachDelegation(address implementation, uint256 privateKey, uint64 nonce) external returns (SignedDelegation memory signedDelegation);
2439
2440 /// Sign an EIP-7702 authorization and designate the next call as an EIP-7702 transaction, with optional cross-chain validity.
2441 #[cheatcode(group = Scripting)]
2442 function signAndAttachDelegation(address implementation, uint256 privateKey, bool crossChain) external returns (SignedDelegation memory signedDelegation);
2443
2444 /// Attach an EIP-4844 blob to the next call
2445 #[cheatcode(group = Scripting)]
2446 function attachBlob(bytes calldata blob) external;
2447
2448 /// Returns addresses of available unlocked wallets in the script environment.
2449 #[cheatcode(group = Scripting)]
2450 function getWallets() external view returns (address[] memory wallets);
2451
2452 // ======== Utilities ========
2453
2454 // -------- Strings --------
2455
2456 /// Converts the given value to a `string`.
2457 #[cheatcode(group = String)]
2458 function toString(address value) external pure returns (string memory stringifiedValue);
2459 /// Converts the given value to a `string`.
2460 #[cheatcode(group = String)]
2461 function toString(bytes calldata value) external pure returns (string memory stringifiedValue);
2462 /// Converts the given value to a `string`.
2463 #[cheatcode(group = String)]
2464 function toString(bytes32 value) external pure returns (string memory stringifiedValue);
2465 /// Converts the given value to a `string`.
2466 #[cheatcode(group = String)]
2467 function toString(bool value) external pure returns (string memory stringifiedValue);
2468 /// Converts the given value to a `string`.
2469 #[cheatcode(group = String)]
2470 function toString(uint256 value) external pure returns (string memory stringifiedValue);
2471 /// Converts the given value to a `string`.
2472 #[cheatcode(group = String)]
2473 function toString(int256 value) external pure returns (string memory stringifiedValue);
2474
2475 /// Parses the given `string` into `bytes`.
2476 #[cheatcode(group = String)]
2477 function parseBytes(string calldata stringifiedValue) external pure returns (bytes memory parsedValue);
2478 /// Parses the given `string` into an `address`.
2479 #[cheatcode(group = String)]
2480 function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue);
2481 /// Parses the given `string` into a `uint256`.
2482 #[cheatcode(group = String)]
2483 function parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue);
2484 /// Parses the given `string` into a `int256`.
2485 #[cheatcode(group = String)]
2486 function parseInt(string calldata stringifiedValue) external pure returns (int256 parsedValue);
2487 /// Parses the given `string` into a `bytes32`.
2488 #[cheatcode(group = String)]
2489 function parseBytes32(string calldata stringifiedValue) external pure returns (bytes32 parsedValue);
2490 /// Parses the given `string` into a `bool`.
2491 #[cheatcode(group = String)]
2492 function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue);
2493
2494 /// Converts the given `string` value to Lowercase.
2495 #[cheatcode(group = String)]
2496 function toLowercase(string calldata input) external pure returns (string memory output);
2497 /// Converts the given `string` value to Uppercase.
2498 #[cheatcode(group = String)]
2499 function toUppercase(string calldata input) external pure returns (string memory output);
2500 /// Trims leading and trailing whitespace from the given `string` value.
2501 #[cheatcode(group = String)]
2502 function trim(string calldata input) external pure returns (string memory output);
2503 /// Replaces occurrences of `from` in the given `string` with `to`.
2504 #[cheatcode(group = String)]
2505 function replace(string calldata input, string calldata from, string calldata to) external pure returns (string memory output);
2506 /// Splits the given `string` into an array of strings divided by the `delimiter`.
2507 #[cheatcode(group = String)]
2508 function split(string calldata input, string calldata delimiter) external pure returns (string[] memory outputs);
2509 /// Returns the index of the first occurrence of a `key` in an `input` string.
2510 /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `key` is not found.
2511 /// Returns 0 in case of an empty `key`.
2512 #[cheatcode(group = String)]
2513 function indexOf(string calldata input, string calldata key) external pure returns (uint256);
2514 /// Returns true if `search` is found in `subject`, false otherwise.
2515 #[cheatcode(group = String)]
2516 function contains(string calldata subject, string calldata search) external pure returns (bool result);
2517
2518 // ======== JSON Parsing and Manipulation ========
2519
2520 // -------- Reading --------
2521
2522 // NOTE: Please read https://book.getfoundry.sh/cheatcodes/parse-json to understand the
2523 // limitations and caveats of the JSON parsing cheats.
2524
2525 /// Checks if `key` exists in a JSON object
2526 /// `keyExists` is being deprecated in favor of `keyExistsJson`. It will be removed in future versions.
2527 #[cheatcode(group = Json, status = Deprecated(Some("replaced by `keyExistsJson`")))]
2528 function keyExists(string calldata json, string calldata key) external view returns (bool);
2529 /// Checks if `key` exists in a JSON object.
2530 #[cheatcode(group = Json)]
2531 function keyExistsJson(string calldata json, string calldata key) external view returns (bool);
2532
2533 /// ABI-encodes a JSON object.
2534 #[cheatcode(group = Json)]
2535 function parseJson(string calldata json) external pure returns (bytes memory abiEncodedData);
2536 /// ABI-encodes a JSON object at `key`.
2537 #[cheatcode(group = Json)]
2538 function parseJson(string calldata json, string calldata key) external pure returns (bytes memory abiEncodedData);
2539
2540 // The following parseJson cheatcodes will do type coercion, for the type that they indicate.
2541 // For example, parseJsonUint will coerce all values to a uint256. That includes stringified numbers '12.'
2542 // and hex numbers '0xEF.'.
2543 // Type coercion works ONLY for discrete values or arrays. That means that the key must return a value or array, not
2544 // a JSON object.
2545
2546 /// Parses a string of JSON data at `key` and coerces it to `uint256`.
2547 #[cheatcode(group = Json)]
2548 function parseJsonUint(string calldata json, string calldata key) external pure returns (uint256);
2549 /// Parses a string of JSON data at `key` and coerces it to `uint256[]`.
2550 #[cheatcode(group = Json)]
2551 function parseJsonUintArray(string calldata json, string calldata key) external pure returns (uint256[] memory);
2552 /// Parses a string of JSON data at `key` and coerces it to `int256`.
2553 #[cheatcode(group = Json)]
2554 function parseJsonInt(string calldata json, string calldata key) external pure returns (int256);
2555 /// Parses a string of JSON data at `key` and coerces it to `int256[]`.
2556 #[cheatcode(group = Json)]
2557 function parseJsonIntArray(string calldata json, string calldata key) external pure returns (int256[] memory);
2558 /// Parses a string of JSON data at `key` and coerces it to `bool`.
2559 #[cheatcode(group = Json)]
2560 function parseJsonBool(string calldata json, string calldata key) external pure returns (bool);
2561 /// Parses a string of JSON data at `key` and coerces it to `bool[]`.
2562 #[cheatcode(group = Json)]
2563 function parseJsonBoolArray(string calldata json, string calldata key) external pure returns (bool[] memory);
2564 /// Parses a string of JSON data at `key` and coerces it to `address`.
2565 #[cheatcode(group = Json)]
2566 function parseJsonAddress(string calldata json, string calldata key) external pure returns (address);
2567 /// Parses a string of JSON data at `key` and coerces it to `address[]`.
2568 #[cheatcode(group = Json)]
2569 function parseJsonAddressArray(string calldata json, string calldata key)
2570 external
2571 pure
2572 returns (address[] memory);
2573 /// Parses a string of JSON data at `key` and coerces it to `string`.
2574 #[cheatcode(group = Json)]
2575 function parseJsonString(string calldata json, string calldata key) external pure returns (string memory);
2576 /// Parses a string of JSON data at `key` and coerces it to `string[]`.
2577 #[cheatcode(group = Json)]
2578 function parseJsonStringArray(string calldata json, string calldata key) external pure returns (string[] memory);
2579 /// Returns the length of the JSON array at `key`.
2580 #[cheatcode(group = Json)]
2581 function parseJsonArrayLength(string calldata json, string calldata key) external pure returns (uint256 length);
2582 /// Parses a string of JSON data at `key` and coerces it to `bytes`.
2583 #[cheatcode(group = Json)]
2584 function parseJsonBytes(string calldata json, string calldata key) external pure returns (bytes memory);
2585 /// Parses a string of JSON data at `key` and coerces it to `bytes[]`.
2586 #[cheatcode(group = Json)]
2587 function parseJsonBytesArray(string calldata json, string calldata key) external pure returns (bytes[] memory);
2588 /// Parses a string of JSON data at `key` and coerces it to `bytes32`.
2589 #[cheatcode(group = Json)]
2590 function parseJsonBytes32(string calldata json, string calldata key) external pure returns (bytes32);
2591 /// Parses a string of JSON data at `key` and coerces it to `bytes32[]`.
2592 #[cheatcode(group = Json)]
2593 function parseJsonBytes32Array(string calldata json, string calldata key)
2594 external
2595 pure
2596 returns (bytes32[] memory);
2597
2598 /// Parses a string of JSON data and coerces it to type corresponding to `typeDescription`.
2599 #[cheatcode(group = Json)]
2600 function parseJsonType(string calldata json, string calldata typeDescription) external pure returns (bytes memory);
2601 /// Parses a string of JSON data at `key` and coerces it to type corresponding to `typeDescription`.
2602 #[cheatcode(group = Json)]
2603 function parseJsonType(string calldata json, string calldata key, string calldata typeDescription) external pure returns (bytes memory);
2604 /// Parses a string of JSON data at `key` and coerces it to type array corresponding to `typeDescription`.
2605 #[cheatcode(group = Json)]
2606 function parseJsonTypeArray(string calldata json, string calldata key, string calldata typeDescription)
2607 external
2608 pure
2609 returns (bytes memory);
2610
2611 /// Returns an array of all the keys in a JSON object.
2612 #[cheatcode(group = Json)]
2613 function parseJsonKeys(string calldata json, string calldata key) external pure returns (string[] memory keys);
2614
2615 // -------- Writing --------
2616
2617 // NOTE: Please read https://book.getfoundry.sh/cheatcodes/serialize-json to understand how
2618 // to use the serialization cheats.
2619
2620 /// Serializes a key and value to a JSON object stored in-memory that can be later written to a file.
2621 /// Returns the stringified version of the specific JSON file up to that moment.
2622 #[cheatcode(group = Json)]
2623 function serializeJson(string calldata objectKey, string calldata value) external returns (string memory json);
2624
2625 /// See `serializeJson`.
2626 #[cheatcode(group = Json)]
2627 function serializeBool(string calldata objectKey, string calldata valueKey, bool value)
2628 external
2629 returns (string memory json);
2630 /// See `serializeJson`.
2631 #[cheatcode(group = Json)]
2632 function serializeUint(string calldata objectKey, string calldata valueKey, uint256 value)
2633 external
2634 returns (string memory json);
2635 /// See `serializeJson`.
2636 #[cheatcode(group = Json)]
2637 function serializeUintToHex(string calldata objectKey, string calldata valueKey, uint256 value)
2638 external
2639 returns (string memory json);
2640 /// See `serializeJson`.
2641 #[cheatcode(group = Json)]
2642 function serializeInt(string calldata objectKey, string calldata valueKey, int256 value)
2643 external
2644 returns (string memory json);
2645 /// See `serializeJson`.
2646 #[cheatcode(group = Json)]
2647 function serializeAddress(string calldata objectKey, string calldata valueKey, address value)
2648 external
2649 returns (string memory json);
2650 /// See `serializeJson`.
2651 #[cheatcode(group = Json)]
2652 function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32 value)
2653 external
2654 returns (string memory json);
2655 /// See `serializeJson`.
2656 #[cheatcode(group = Json)]
2657 function serializeString(string calldata objectKey, string calldata valueKey, string calldata value)
2658 external
2659 returns (string memory json);
2660 /// See `serializeJson`.
2661 #[cheatcode(group = Json)]
2662 function serializeBytes(string calldata objectKey, string calldata valueKey, bytes calldata value)
2663 external
2664 returns (string memory json);
2665
2666 /// See `serializeJson`.
2667 #[cheatcode(group = Json)]
2668 function serializeBool(string calldata objectKey, string calldata valueKey, bool[] calldata values)
2669 external
2670 returns (string memory json);
2671 /// See `serializeJson`.
2672 #[cheatcode(group = Json)]
2673 function serializeUint(string calldata objectKey, string calldata valueKey, uint256[] calldata values)
2674 external
2675 returns (string memory json);
2676 /// See `serializeJson`.
2677 #[cheatcode(group = Json)]
2678 function serializeInt(string calldata objectKey, string calldata valueKey, int256[] calldata values)
2679 external
2680 returns (string memory json);
2681 /// See `serializeJson`.
2682 #[cheatcode(group = Json)]
2683 function serializeAddress(string calldata objectKey, string calldata valueKey, address[] calldata values)
2684 external
2685 returns (string memory json);
2686 /// See `serializeJson`.
2687 #[cheatcode(group = Json)]
2688 function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32[] calldata values)
2689 external
2690 returns (string memory json);
2691 /// See `serializeJson`.
2692 #[cheatcode(group = Json)]
2693 function serializeString(string calldata objectKey, string calldata valueKey, string[] calldata values)
2694 external
2695 returns (string memory json);
2696 /// See `serializeJson`.
2697 #[cheatcode(group = Json)]
2698 function serializeBytes(string calldata objectKey, string calldata valueKey, bytes[] calldata values)
2699 external
2700 returns (string memory json);
2701 /// See `serializeJson`.
2702 #[cheatcode(group = Json)]
2703 function serializeJsonType(string calldata typeDescription, bytes calldata value)
2704 external
2705 pure
2706 returns (string memory json);
2707 /// See `serializeJson`.
2708 #[cheatcode(group = Json)]
2709 function serializeJsonType(string calldata objectKey, string calldata valueKey, string calldata typeDescription, bytes calldata value)
2710 external
2711 returns (string memory json);
2712
2713 // NOTE: Please read https://book.getfoundry.sh/cheatcodes/write-json to understand how
2714 // to use the JSON writing cheats.
2715
2716 /// Write a serialized JSON object to a file. If the file exists, it will be overwritten.
2717 #[cheatcode(group = Json)]
2718 function writeJson(string calldata json, string calldata path) external;
2719
2720 /// Write a serialized JSON object to an **existing** JSON file, replacing a value with key = <value_key.>
2721 /// This is useful to replace a specific value of a JSON file, without having to parse the entire thing.
2722 /// This cheatcode will create new keys if they didn't previously exist.
2723 #[cheatcode(group = Json)]
2724 function writeJson(string calldata json, string calldata path, string calldata valueKey) external;
2725
2726 // ======== TOML Parsing and Manipulation ========
2727
2728 // -------- Reading --------
2729
2730 // NOTE: Please read https://book.getfoundry.sh/cheatcodes/parse-toml to understand the
2731 // limitations and caveats of the TOML parsing cheat.
2732
2733 /// Checks if `key` exists in a TOML table.
2734 #[cheatcode(group = Toml)]
2735 function keyExistsToml(string calldata toml, string calldata key) external view returns (bool);
2736
2737 /// ABI-encodes a TOML table.
2738 #[cheatcode(group = Toml)]
2739 function parseToml(string calldata toml) external pure returns (bytes memory abiEncodedData);
2740
2741 /// ABI-encodes a TOML table at `key`.
2742 #[cheatcode(group = Toml)]
2743 function parseToml(string calldata toml, string calldata key) external pure returns (bytes memory abiEncodedData);
2744
2745 // The following parseToml cheatcodes will do type coercion, for the type that they indicate.
2746 // For example, parseTomlUint will coerce all values to a uint256. That includes stringified numbers '12.'
2747 // and hex numbers '0xEF.'.
2748 // Type coercion works ONLY for discrete values or arrays. That means that the key must return a value or array, not
2749 // a TOML table.
2750
2751 /// Parses a string of TOML data at `key` and coerces it to `uint256`.
2752 #[cheatcode(group = Toml)]
2753 function parseTomlUint(string calldata toml, string calldata key) external pure returns (uint256);
2754 /// Parses a string of TOML data at `key` and coerces it to `uint256[]`.
2755 #[cheatcode(group = Toml)]
2756 function parseTomlUintArray(string calldata toml, string calldata key) external pure returns (uint256[] memory);
2757 /// Parses a string of TOML data at `key` and coerces it to `int256`.
2758 #[cheatcode(group = Toml)]
2759 function parseTomlInt(string calldata toml, string calldata key) external pure returns (int256);
2760 /// Parses a string of TOML data at `key` and coerces it to `int256[]`.
2761 #[cheatcode(group = Toml)]
2762 function parseTomlIntArray(string calldata toml, string calldata key) external pure returns (int256[] memory);
2763 /// Parses a string of TOML data at `key` and coerces it to `bool`.
2764 #[cheatcode(group = Toml)]
2765 function parseTomlBool(string calldata toml, string calldata key) external pure returns (bool);
2766 /// Parses a string of TOML data at `key` and coerces it to `bool[]`.
2767 #[cheatcode(group = Toml)]
2768 function parseTomlBoolArray(string calldata toml, string calldata key) external pure returns (bool[] memory);
2769 /// Parses a string of TOML data at `key` and coerces it to `address`.
2770 #[cheatcode(group = Toml)]
2771 function parseTomlAddress(string calldata toml, string calldata key) external pure returns (address);
2772 /// Parses a string of TOML data at `key` and coerces it to `address[]`.
2773 #[cheatcode(group = Toml)]
2774 function parseTomlAddressArray(string calldata toml, string calldata key)
2775 external
2776 pure
2777 returns (address[] memory);
2778 /// Parses a string of TOML data at `key` and coerces it to `string`.
2779 #[cheatcode(group = Toml)]
2780 function parseTomlString(string calldata toml, string calldata key) external pure returns (string memory);
2781 /// Parses a string of TOML data at `key` and coerces it to `string[]`.
2782 #[cheatcode(group = Toml)]
2783 function parseTomlStringArray(string calldata toml, string calldata key) external pure returns (string[] memory);
2784 /// Parses a string of TOML data at `key` and coerces it to `bytes`.
2785 #[cheatcode(group = Toml)]
2786 function parseTomlBytes(string calldata toml, string calldata key) external pure returns (bytes memory);
2787 /// Parses a string of TOML data at `key` and coerces it to `bytes[]`.
2788 #[cheatcode(group = Toml)]
2789 function parseTomlBytesArray(string calldata toml, string calldata key) external pure returns (bytes[] memory);
2790 /// Parses a string of TOML data at `key` and coerces it to `bytes32`.
2791 #[cheatcode(group = Toml)]
2792 function parseTomlBytes32(string calldata toml, string calldata key) external pure returns (bytes32);
2793 /// Parses a string of TOML data at `key` and coerces it to `bytes32[]`.
2794 #[cheatcode(group = Toml)]
2795 function parseTomlBytes32Array(string calldata toml, string calldata key)
2796 external
2797 pure
2798 returns (bytes32[] memory);
2799
2800 /// Parses a string of TOML data and coerces it to type corresponding to `typeDescription`.
2801 #[cheatcode(group = Toml)]
2802 function parseTomlType(string calldata toml, string calldata typeDescription) external pure returns (bytes memory);
2803 /// Parses a string of TOML data at `key` and coerces it to type corresponding to `typeDescription`.
2804 #[cheatcode(group = Toml)]
2805 function parseTomlType(string calldata toml, string calldata key, string calldata typeDescription) external pure returns (bytes memory);
2806 /// Parses a string of TOML data at `key` and coerces it to type array corresponding to `typeDescription`.
2807 #[cheatcode(group = Toml)]
2808 function parseTomlTypeArray(string calldata toml, string calldata key, string calldata typeDescription)
2809 external
2810 pure
2811 returns (bytes memory);
2812
2813 /// Returns an array of all the keys in a TOML table.
2814 #[cheatcode(group = Toml)]
2815 function parseTomlKeys(string calldata toml, string calldata key) external pure returns (string[] memory keys);
2816
2817 // -------- Writing --------
2818
2819 // NOTE: Please read https://book.getfoundry.sh/cheatcodes/write-toml to understand how
2820 // to use the TOML writing cheat.
2821
2822 /// Takes serialized JSON, converts to TOML and write a serialized TOML to a file.
2823 #[cheatcode(group = Toml)]
2824 function writeToml(string calldata json, string calldata path) external;
2825
2826 /// Takes serialized JSON, converts to TOML and write a serialized TOML table to an **existing** TOML file, replacing a value with key = <value_key.>
2827 /// This is useful to replace a specific value of a TOML file, without having to parse the entire thing.
2828 /// This cheatcode will create new keys if they didn't previously exist.
2829 #[cheatcode(group = Toml)]
2830 function writeToml(string calldata json, string calldata path, string calldata valueKey) external;
2831
2832 // ======== Cryptography ========
2833
2834 // -------- Key Management --------
2835
2836 /// Derives a private key from the name, labels the account with that name, and returns the wallet.
2837 #[cheatcode(group = Crypto)]
2838 function createWallet(string calldata walletLabel) external returns (Wallet memory wallet);
2839
2840 /// Generates a wallet from the private key and returns the wallet.
2841 #[cheatcode(group = Crypto)]
2842 function createWallet(uint256 privateKey) external returns (Wallet memory wallet);
2843
2844 /// Generates a wallet from the private key, labels the account with that name, and returns the wallet.
2845 #[cheatcode(group = Crypto)]
2846 function createWallet(uint256 privateKey, string calldata walletLabel) external returns (Wallet memory wallet);
2847
2848 /// Signs data with a `Wallet`.
2849 #[cheatcode(group = Crypto)]
2850 function sign(Wallet calldata wallet, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
2851
2852 /// Signs data with a `Wallet`.
2853 ///
2854 /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the
2855 /// signature's `s` value, and the recovery id `v` in a single bytes32.
2856 /// This format reduces the signature size from 65 to 64 bytes.
2857 #[cheatcode(group = Crypto)]
2858 function signCompact(Wallet calldata wallet, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
2859
2860 /// Signs `digest` with `privateKey` using the secp256k1 curve.
2861 #[cheatcode(group = Crypto)]
2862 function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
2863
2864 /// Signs `digest` with `privateKey` on the secp256k1 curve, using the given `nonce`
2865 /// as the raw ephemeral k value in ECDSA (instead of deriving it deterministically).
2866 #[cheatcode(group = Crypto)]
2867 function signWithNonceUnsafe(uint256 privateKey, bytes32 digest, uint256 nonce) external pure returns (uint8 v, bytes32 r, bytes32 s);
2868
2869 /// Signs `digest` as a Tempo V2 keychain signature for `account` using a secp256k1 access key.
2870 ///
2871 /// Returns the encoded signature bytes accepted by `SignatureVerifier.verifyKeychain`.
2872 #[cheatcode(group = Crypto)]
2873 function signKeychain(uint256 privateKey, address account, bytes32 digest) external pure returns (bytes memory signature);
2874
2875 /// Signs `digest` as a Tempo V2 keychain signature for `account` using a root or admin secp256k1 key.
2876 ///
2877 /// Returns the encoded signature bytes accepted by `SignatureVerifier.verifyKeychainAdmin`.
2878 /// The supplied `digest` should already be domain-separated with chain ID, contract address,
2879 /// and account address.
2880 #[cheatcode(group = Crypto)]
2881 function signKeychainAdmin(uint256 privateKey, address account, bytes32 digest) external pure returns (bytes memory signature);
2882
2883 /// Signs `digest` with `privateKey` using the secp256k1 curve.
2884 ///
2885 /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the
2886 /// signature's `s` value, and the recovery id `v` in a single bytes32.
2887 /// This format reduces the signature size from 65 to 64 bytes.
2888 #[cheatcode(group = Crypto)]
2889 function signCompact(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
2890
2891 /// Signs `digest` with signer provided to script using the secp256k1 curve.
2892 ///
2893 /// If `--sender` is provided, the signer with provided address is used, otherwise,
2894 /// if exactly one signer is provided to the script, that signer is used.
2895 ///
2896 /// Raises error if signer passed through `--sender` does not match any unlocked signers or
2897 /// if `--sender` is not provided and not exactly one signer is passed to the script.
2898 #[cheatcode(group = Crypto)]
2899 function sign(bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
2900
2901 /// Signs `digest` with signer provided to script using the secp256k1 curve.
2902 ///
2903 /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the
2904 /// signature's `s` value, and the recovery id `v` in a single bytes32.
2905 /// This format reduces the signature size from 65 to 64 bytes.
2906 ///
2907 /// If `--sender` is provided, the signer with provided address is used, otherwise,
2908 /// if exactly one signer is provided to the script, that signer is used.
2909 ///
2910 /// Raises error if signer passed through `--sender` does not match any unlocked signers or
2911 /// if `--sender` is not provided and not exactly one signer is passed to the script.
2912 #[cheatcode(group = Crypto)]
2913 function signCompact(bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
2914
2915 /// Signs `digest` with signer provided to script using the secp256k1 curve.
2916 ///
2917 /// Raises error if none of the signers passed into the script have provided address.
2918 #[cheatcode(group = Crypto)]
2919 function sign(address signer, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
2920
2921 /// Signs `digest` with signer provided to script using the secp256k1 curve.
2922 ///
2923 /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the
2924 /// signature's `s` value, and the recovery id `v` in a single bytes32.
2925 /// This format reduces the signature size from 65 to 64 bytes.
2926 ///
2927 /// Raises error if none of the signers passed into the script have provided address.
2928 #[cheatcode(group = Crypto)]
2929 function signCompact(address signer, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
2930
2931 /// Signs `digest` with `privateKey` using the secp256r1 curve.
2932 #[cheatcode(group = Crypto)]
2933 function signP256(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 s);
2934
2935 /// Derives secp256r1 public key from the provided `privateKey`.
2936 #[cheatcode(group = Crypto)]
2937 function publicKeyP256(uint256 privateKey) external pure returns (uint256 publicKeyX, uint256 publicKeyY);
2938
2939 /// Generates an Ed25519 key pair from a deterministic salt.
2940 /// Returns (publicKey, privateKey) as 32-byte values.
2941 #[cheatcode(group = Crypto, safety = Safe)]
2942 function createEd25519Key(bytes32 salt) external pure returns (bytes32 publicKey, bytes32 privateKey);
2943
2944 /// Derives the Ed25519 public key from a private key.
2945 #[cheatcode(group = Crypto, safety = Safe)]
2946 function publicKeyEd25519(bytes32 privateKey) external pure returns (bytes32 publicKey);
2947
2948 /// Signs a message with namespace using Ed25519.
2949 /// The signature covers namespace || message for domain separation.
2950 /// Returns a 64-byte Ed25519 signature.
2951 #[cheatcode(group = Crypto, safety = Safe)]
2952 function signEd25519(bytes calldata namespace, bytes calldata message, bytes32 privateKey)
2953 external
2954 pure
2955 returns (bytes memory signature);
2956
2957 /// Verifies an Ed25519 signature over namespace || message.
2958 /// Returns true if signature is valid, false otherwise.
2959 #[cheatcode(group = Crypto, safety = Safe)]
2960 function verifyEd25519(
2961 bytes calldata signature,
2962 bytes calldata namespace,
2963 bytes calldata message,
2964 bytes32 publicKey
2965 ) external pure returns (bool valid);
2966
2967 /// Derive a private key from a provided mnemonic string (or mnemonic file path)
2968 /// at the derivation path `m/44'/60'/0'/0/{index}`.
2969 #[cheatcode(group = Crypto)]
2970 function deriveKey(string calldata mnemonic, uint32 index) external pure returns (uint256 privateKey);
2971 /// Derive a private key from a provided mnemonic string (or mnemonic file path)
2972 /// at `{derivationPath}{index}`.
2973 #[cheatcode(group = Crypto)]
2974 function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index)
2975 external
2976 pure
2977 returns (uint256 privateKey);
2978 /// Derive a private key from a provided mnemonic string (or mnemonic file path) in the specified language
2979 /// at the derivation path `m/44'/60'/0'/0/{index}`.
2980 #[cheatcode(group = Crypto)]
2981 function deriveKey(string calldata mnemonic, uint32 index, string calldata language)
2982 external
2983 pure
2984 returns (uint256 privateKey);
2985 /// Derive a private key from a provided mnemonic string (or mnemonic file path) in the specified language
2986 /// at `{derivationPath}{index}`.
2987 #[cheatcode(group = Crypto)]
2988 function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index, string calldata language)
2989 external
2990 pure
2991 returns (uint256 privateKey);
2992
2993 /// Adds a private key to the local forge wallet and returns the address.
2994 #[cheatcode(group = Crypto)]
2995 function rememberKey(uint256 privateKey) external returns (address keyAddr);
2996
2997 /// Derive a set number of wallets from a mnemonic at the derivation path `m/44'/60'/0'/0/{0..count}`.
2998 ///
2999 /// The respective private keys are saved to the local forge wallet for later use and their addresses are returned.
3000 #[cheatcode(group = Crypto)]
3001 function rememberKeys(string calldata mnemonic, string calldata derivationPath, uint32 count) external returns (address[] memory keyAddrs);
3002
3003 /// Derive a set number of wallets from a mnemonic in the specified language at the derivation path `m/44'/60'/0'/0/{0..count}`.
3004 ///
3005 /// The respective private keys are saved to the local forge wallet for later use and their addresses are returned.
3006 #[cheatcode(group = Crypto)]
3007 function rememberKeys(string calldata mnemonic, string calldata derivationPath, string calldata language, uint32 count)
3008 external
3009 returns (address[] memory keyAddrs);
3010
3011 // -------- Uncategorized Utilities --------
3012
3013 /// Labels an address in call traces.
3014 #[cheatcode(group = Utilities)]
3015 function label(address account, string calldata newLabel) external;
3016
3017 /// Gets the label for the specified address.
3018 #[cheatcode(group = Utilities)]
3019 function getLabel(address account) external view returns (string memory currentLabel);
3020
3021 /// Compute the address a contract will be deployed at for a given deployer address and nonce.
3022 #[cheatcode(group = Utilities)]
3023 function computeCreateAddress(address deployer, uint256 nonce) external pure returns (address);
3024
3025 /// Compute the address of a contract created with CREATE2 using the given CREATE2 deployer.
3026 #[cheatcode(group = Utilities)]
3027 function computeCreate2Address(bytes32 salt, bytes32 initCodeHash, address deployer) external pure returns (address);
3028
3029 /// Compute the address of a contract created with CREATE2 using the default CREATE2 deployer.
3030 #[cheatcode(group = Utilities)]
3031 function computeCreate2Address(bytes32 salt, bytes32 initCodeHash) external pure returns (address);
3032
3033 /// Encodes a `bytes` value to a base64 string.
3034 #[cheatcode(group = Utilities)]
3035 function toBase64(bytes calldata data) external pure returns (string memory);
3036
3037 /// Encodes a `string` value to a base64 string.
3038 #[cheatcode(group = Utilities)]
3039 function toBase64(string calldata data) external pure returns (string memory);
3040
3041 /// Encodes a `bytes` value to a base64url string.
3042 #[cheatcode(group = Utilities)]
3043 function toBase64URL(bytes calldata data) external pure returns (string memory);
3044
3045 /// Encodes a `string` value to a base64url string.
3046 #[cheatcode(group = Utilities)]
3047 function toBase64URL(string calldata data) external pure returns (string memory);
3048
3049 /// Returns ENS namehash for provided string.
3050 #[cheatcode(group = Utilities)]
3051 function ensNamehash(string calldata name) external pure returns (bytes32);
3052
3053 /// Returns an uint256 value bounded in given range and different from the current one.
3054 #[cheatcode(group = Utilities)]
3055 function bound(uint256 current, uint256 min, uint256 max) external view returns (uint256);
3056
3057 /// Returns a random uint256 value.
3058 #[cheatcode(group = Utilities)]
3059 function randomUint() external view returns (uint256);
3060
3061 /// Returns random uint256 value between the provided range (=min..=max).
3062 #[cheatcode(group = Utilities)]
3063 function randomUint(uint256 min, uint256 max) external view returns (uint256);
3064
3065 /// Returns a random `uint256` value of given bits.
3066 #[cheatcode(group = Utilities)]
3067 function randomUint(uint256 bits) external view returns (uint256);
3068
3069 /// Returns a random `address`.
3070 #[cheatcode(group = Utilities)]
3071 function randomAddress() external view returns (address);
3072
3073 /// Returns an int256 value bounded in given range and different from the current one.
3074 #[cheatcode(group = Utilities)]
3075 function bound(int256 current, int256 min, int256 max) external view returns (int256);
3076
3077 /// Returns a random `int256` value.
3078 #[cheatcode(group = Utilities)]
3079 function randomInt() external view returns (int256);
3080
3081 /// Returns a random `int256` value of given bits.
3082 #[cheatcode(group = Utilities)]
3083 function randomInt(uint256 bits) external view returns (int256);
3084
3085 /// Returns a random `bool`.
3086 #[cheatcode(group = Utilities)]
3087 function randomBool() external view returns (bool);
3088
3089 /// Returns a random byte array value of the given length.
3090 #[cheatcode(group = Utilities)]
3091 function randomBytes(uint256 len) external view returns (bytes memory);
3092
3093 /// Returns a random fixed-size byte array of length 4.
3094 #[cheatcode(group = Utilities)]
3095 function randomBytes4() external view returns (bytes4);
3096
3097 /// Returns a random fixed-size byte array of length 8.
3098 #[cheatcode(group = Utilities)]
3099 function randomBytes8() external view returns (bytes8);
3100
3101 /// Pauses collection of call traces. Useful in cases when you want to skip tracing of
3102 /// complex calls which are not useful for debugging.
3103 #[cheatcode(group = Utilities)]
3104 function pauseTracing() external view;
3105
3106 /// Unpauses collection of call traces.
3107 #[cheatcode(group = Utilities)]
3108 function resumeTracing() external view;
3109
3110 /// Utility cheatcode to copy storage of `from` contract to another `to` contract.
3111 #[cheatcode(group = Utilities, safety = Unsafe)]
3112 function copyStorage(address from, address to) external;
3113
3114 /// Utility cheatcode to set arbitrary storage for given target address.
3115 #[cheatcode(group = Utilities, safety = Unsafe)]
3116 function setArbitraryStorage(address target) external;
3117
3118 /// Utility cheatcode to set arbitrary storage for given target address and overwrite
3119 /// any storage slots that have been previously set.
3120 #[cheatcode(group = Utilities, safety = Unsafe)]
3121 function setArbitraryStorage(address target, bool overwrite) external;
3122
3123 /// Sorts an array in ascending order.
3124 #[cheatcode(group = Utilities)]
3125 function sort(uint256[] calldata array) external returns (uint256[] memory);
3126
3127 /// Randomly shuffles an array.
3128 #[cheatcode(group = Utilities)]
3129 function shuffle(uint256[] calldata array) external returns (uint256[] memory);
3130
3131 /// Set RNG seed.
3132 #[cheatcode(group = Utilities)]
3133 function setSeed(uint256 seed) external;
3134
3135 /// Causes the next contract creation (via new) to fail and return its initcode in the returndata buffer.
3136 /// This allows type-safe access to the initcode payload that would be used for contract creation.
3137 /// Example usage:
3138 /// vm.interceptInitcode();
3139 /// bytes memory initcode;
3140 /// try new MyContract(param1, param2) { assert(false); }
3141 /// catch (bytes memory interceptedInitcode) { initcode = interceptedInitcode; }
3142 #[cheatcode(group = Utilities, safety = Unsafe)]
3143 function interceptInitcode() external;
3144
3145 /// Generates the hash of the canonical EIP-712 type representation.
3146 ///
3147 /// Supports 2 different inputs:
3148 /// 1. Name of the type (i.e. "Transaction"):
3149 /// * requires previous binding generation with `forge bind-json`.
3150 /// * bindings will be retrieved from the path configured in `foundry.toml`.
3151 ///
3152 /// 2. String representation of the type (i.e. "Foo(Bar bar) Bar(uint256 baz)").
3153 /// * Note: the cheatcode will output the canonical type even if the input is malformed
3154 /// with the wrong order of elements or with extra whitespaces.
3155 #[cheatcode(group = Utilities)]
3156 function eip712HashType(string calldata typeNameOrDefinition) external pure returns (bytes32 typeHash);
3157
3158 /// Generates the hash of the canonical EIP-712 type representation.
3159 /// Requires previous binding generation with `forge bind-json`.
3160 ///
3161 /// Params:
3162 /// * `bindingsPath`: path where the output of `forge bind-json` is stored.
3163 /// * `typeName`: Name of the type (i.e. "Transaction").
3164 #[cheatcode(group = Utilities)]
3165 function eip712HashType(string calldata bindingsPath, string calldata typeName) external pure returns (bytes32 typeHash);
3166
3167 /// Generates the struct hash of the canonical EIP-712 type representation and its abi-encoded data.
3168 ///
3169 /// Supports 2 different inputs:
3170 /// 1. Name of the type (i.e. "PermitSingle"):
3171 /// * requires previous binding generation with `forge bind-json`.
3172 /// * bindings will be retrieved from the path configured in `foundry.toml`.
3173 ///
3174 /// 2. String representation of the type (i.e. "Foo(Bar bar) Bar(uint256 baz)").
3175 /// * Note: the cheatcode will use the canonical type even if the input is malformed
3176 /// with the wrong order of elements or with extra whitespaces.
3177 #[cheatcode(group = Utilities)]
3178 function eip712HashStruct(string calldata typeNameOrDefinition, bytes calldata abiEncodedData) external pure returns (bytes32 typeHash);
3179
3180 /// Generates the struct hash of the canonical EIP-712 type representation and its abi-encoded data.
3181 /// Requires previous binding generation with `forge bind-json`.
3182 ///
3183 /// Params:
3184 /// * `bindingsPath`: path where the output of `forge bind-json` is stored.
3185 /// * `typeName`: Name of the type (i.e. "PermitSingle").
3186 /// * `abiEncodedData`: ABI-encoded data for the struct that is being hashed.
3187 #[cheatcode(group = Utilities)]
3188 function eip712HashStruct(string calldata bindingsPath, string calldata typeName, bytes calldata abiEncodedData) external pure returns (bytes32 typeHash);
3189
3190 /// Generates a ready-to-sign digest of human-readable typed data following the EIP-712 standard.
3191 #[cheatcode(group = Utilities)]
3192 function eip712HashTypedData(string calldata jsonData) external pure returns (bytes32 digest);
3193
3194 /// RLP encodes a list of bytes into an RLP payload.
3195 #[cheatcode(group = Utilities)]
3196 function toRlp(bytes[] calldata data) external pure returns (bytes memory);
3197 /// RLP decodes an RLP payload into a list of bytes.
3198 #[cheatcode(group = Utilities)]
3199 function fromRlp(bytes calldata rlp) external pure returns (bytes[] memory data);
3200}
3201}
3202
3203impl PartialEq for ForgeContext {
3204 // Handles test group case (any of test, coverage or snapshot)
3205 // and script group case (any of dry run, broadcast or resume).
3206 fn eq(&self, other: &Self) -> bool {
3207 match (self, other) {
3208 (_, Self::TestGroup) => {
3209 matches!(self, Self::Test | Self::Snapshot | Self::Coverage)
3210 }
3211 (_, Self::ScriptGroup) => {
3212 matches!(self, Self::ScriptDryRun | Self::ScriptBroadcast | Self::ScriptResume)
3213 }
3214 (Self::Test, Self::Test)
3215 | (Self::Snapshot, Self::Snapshot)
3216 | (Self::Coverage, Self::Coverage)
3217 | (Self::ScriptDryRun, Self::ScriptDryRun)
3218 | (Self::ScriptBroadcast, Self::ScriptBroadcast)
3219 | (Self::ScriptResume, Self::ScriptResume)
3220 | (Self::Unknown, Self::Unknown) => true,
3221 _ => false,
3222 }
3223 }
3224}
3225
3226impl fmt::Display for Vm::CheatcodeError {
3227 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3228 self.message.fmt(f)
3229 }
3230}
3231
3232impl fmt::Display for Vm::VmErrors {
3233 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3234 match self {
3235 Self::CheatcodeError(err) => err.fmt(f),
3236 }
3237 }
3238}
3239
3240#[track_caller]
3241const fn panic_unknown_safety() -> ! {
3242 panic!("cannot determine safety from the group, add a `#[cheatcode(safety = ...)]` attribute")
3243}