Skip to content

Commit d073f35

Browse files
authored
add ERC20 version of deal cheatcode (#835)
* add ERC20 version of deal cheatcode added: // Set the balance of an account for any ERC20 token function deal(address token, address to, uint256 give) external; // Alternative signature to update `totalSupply` function deal(address token, address to, uint256 give, bool adjust) external; * add ERC20 option of deal to book added: ```solidity function deal(address token, address to, uint256 give) external; ``` ```solidity function deal(address token, address to, uint256 give, bool adjust) external; ``` If the alternative signature of `deal` is used, then we can additionaly specify ERC20 token address, as well as an option to update `totalSupply`. ```solidity address alice = address(1); vm.deal(DAI, alice, 1 ether); log_uint256(DAI.balanceOf(alice); // 1000000000000000000 ``` * address(DAI)
1 parent 91593f4 commit d073f35

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/cheatcodes/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@ interface CheatCodes {
174174
// Sets an address' balance
175175
function deal(address who, uint256 newBalance) external;
176176
177+
// Set the balance of an account for any ERC20 token
178+
function deal(address token, address to, uint256 give) external;
179+
180+
// Alternative signature to update `totalSupply`
181+
function deal(address token, address to, uint256 give, bool adjust) external;
182+
177183
// Sets an address' code
178184
function etch(address who, bytes calldata code) external;
179185

src/cheatcodes/deal.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,20 @@
66
function deal(address who, uint256 newBalance) external;
77
```
88

9+
```solidity
10+
function deal(address token, address to, uint256 give) external;
11+
```
12+
13+
```solidity
14+
function deal(address token, address to, uint256 give, bool adjust) external;
15+
```
16+
917
### Description
1018

1119
Sets the balance of an address `who` to `newBalance`.
1220

21+
If the alternative signature of `deal` is used, then we can additionaly specify ERC20 token address, as well as an option to update `totalSupply`.
22+
1323
### Examples
1424

1525
```solidity
@@ -18,6 +28,12 @@ vm.deal(alice, 1 ether);
1828
log_uint256(alice.balance); // 1000000000000000000
1929
```
2030

31+
```solidity
32+
address alice = address(1);
33+
vm.deal(address(DAI), alice, 1 ether);
34+
log_uint256(address(DAI).balanceOf(alice); // 1000000000000000000
35+
```
36+
2137
### SEE ALSO
2238

2339
Forge Standard Library

0 commit comments

Comments
 (0)