> For the complete documentation index, see [llms.txt](https://ret2basic.gitbook.io/ctfnote/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ret2basic.gitbook.io/ctfnote/web3-security-research/foundry/mint-1-million-dai-on-mainnet-fork.md).

# Mint 1 Million DAI on Mainnet Fork

{% embed url="<https://youtu.be/I8mzJxMBzs0>" %}
Mint 1 Million DAI on Mainnet Fork
{% endembed %}

## Setup

Test file:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

import "forge-std/Test.sol";
import "forge-std/console.sol";
import "../src/interfaces/IERC20.sol";

contract ForkTest is Test {
    IERC20 public dai;

    function setUp() public {
        dai = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F);
    }

    function testDeposit() public {
        address alice = address(123);

        uint256 balBefore = dai.balanceOf(alice);
        console.log("balance before", balBefore);

        uint256 totalBefore = dai.totalSupply();
        console.log("total supply before", totalBefore / 1e18);

        // token, account, amount, adjust total supply
        deal(address(dai), alice, 1e6 * 1e18, true);

        uint256 balAfter = dai.balanceOf(alice);
        console.log("balance after", balAfter / 1e18);

        uint256 totalAfter = dai.totalSupply();
        console.log("total supply after", totalAfter / 1e18);
    }
}
```

## deal tokens

Beyond setting ETH balance, `deal()` can also set token balance:

{% embed url="<https://book.getfoundry.sh/reference/forge-std/deal>" %}

<figure><img src="https://3988450783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWVjG_njKgBtvmnKaJh%2Fuploads%2FxjIc97vBpkz7XNpqdQqL%2Fimage.png?alt=media&amp;token=31c975b5-4f29-4f36-9ec9-e66217f92b50" alt=""><figcaption></figcaption></figure>

The `bool adjust` thing increments the totalSupply of Dai.
