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