Skip to content

Commit

Permalink
Update create-wallet.md (#1338)
Browse files Browse the repository at this point in the history
The guidance provided by the foundry book informs us to setup our tests via
```
contract MyTest is Test {
...
}
```

However, given the inheritance and import structures of `forge-std/Test.sol`, the documentation to create a wallet produces the following error:

```
Compiler run failed:
Error (7920): Identifier not found or not unique.
  --> test/MyTest.t.sol:86:5:
   |
86 |     Wallet memory _w = vm.createWallet(100);
   |     ^^^^^^

Error: 
```

Instead, in order to store the result returned by `vm.createWallet`, I had to reference the `Wallet` type through the `Vm` interface, like so:
```
Vm.Wallet memory _w = vm.createWallet(100);
```
  • Loading branch information
juannyG authored Oct 23, 2024
1 parent 4317603 commit c354d9d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/cheatcodes/create-wallet.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Creates a new Wallet struct when given a parameter to derive the private key fro
#### `uint256`

```solidity
Wallet memory wallet = vm.createWallet(uint256(keccak256(bytes("1"))));
Vm.Wallet memory wallet = vm.createWallet(uint256(keccak256(bytes("1"))));
emit log_uint(wallet.privateKey); // uint256(keccak256(bytes("1")))
Expand All @@ -58,7 +58,7 @@ emit log_string(vm.getLabel(wallet.addr)); // ""
#### `string`

```solidity
Wallet memory wallet = vm.createWallet("bob's wallet");
Vm.Wallet memory wallet = vm.createWallet("bob's wallet");
emit log_uint(wallet.privateKey); // uint256(keccak256(bytes("bob's wallet")))
Expand All @@ -80,7 +80,7 @@ emit log_string(vm.getLabel(wallet.addr)); // "bob's wallet"
#### `uint256` and `string`

```solidity
Wallet memory wallet = vm.createWallet(uint256(keccak256(bytes("1"))), "bob's wallet");
Vm.Wallet memory wallet = vm.createWallet(uint256(keccak256(bytes("1"))), "bob's wallet");
emit log_uint(wallet.privateKey); // uint256(keccak256(bytes("1")))
Expand Down

0 comments on commit c354d9d

Please sign in to comment.