How can i use anvil accounts into the foundry tests? Like in hardhat node i can getNamedAccounts() but how can I use the anvil accounts into my forge Tests?

1 Answer 1


I'm a little unsure on this one, although I just made a quick search in the Foundry documentation and on the World Wide Web in general, which I believe you've also tried yourself before asking. So:

To my knowledge there's no such functionality in Foundry. There are, however, a lot of ways to make use of accounts in tests using Anvil. The most obvious is to copy-paste the private keys used in Anvil and make use of them in your tests in any way you want.

Hope this will give some clarification on your issue. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.