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