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