Blockchain security isn't optional.
Protect your smart contracts and DeFi protocols with Three Sigma, a trusted security partner in blockchain audits, smart contract vulnerability assessments, and Web3 security.
Get a Quote Today
Introduction
After learning to bend time in Part 4, it’s only fair we mint some ether too. This chapter shows how vm.deal
instantly tops up any address, no faucets, no transfers, so you can simulate rich users, pay gas, or test payable flows with zero friction.
What vm.deal
Does
In tests you often need an account to have ETH (e.g. to pay gas or make a payable call). The vm.deal(address who, uint256 newBalance)
cheatcode simply sets the Ether balance of who
to newBalance
. For example:

Here vm.deal(rich, 10 ether)
minted 10 ETH to rich
before the test action. The Foundry cheatcode docs explain it “sets the balance of an address who
to newBalance
”. It even supports tokens: a variant lets you set ERC20 balances and adjust total supply if needed.
Why It's Useful
This is far simpler than transferring from a mainnet account or writing a faucet in the test. It’s ideal for testing contracts that require the caller to have a certain balance. For instance, if a contract requires a deposit, you can deal that much ETH to the test user and proceed.
Conclusion
In summary, vm.deal
removes friction when setting up account balances in a test, letting you focus on the logic being tested rather than on funding accounts manually. It’s one of the most straightforward yet powerful cheatcodes in the Foundry toolbox.