<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/mocking-addresses-without-private-keys-in-hardhat-tests-ez5q1pwui" -->

---
title: Mocking Addresses Without Private Keys in Hardhat Tests
description: Learn how to test smart contracts without the private key for an address using Hardhat&#x27;s impersonate account mechanism. Verify access control and test...
canonical: https://daily.dev/posts/mocking-addresses-without-private-keys-in-hardhat-tests-ez5q1pwui
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Mocking Addresses Without Private Keys in Hardhat Tests | daily.dev
og:description: Learn how to test smart contracts without the private key for an address using Hardhat&#x27;s impersonate account mechanism. Verify access control and test...
og:url: https://daily.dev/posts/mocking-addresses-without-private-keys-in-hardhat-tests-ez5q1pwui
og:image: https://api.daily.dev/og/posts/eZ5q1pWuI.png
og:image:alt: Mocking Addresses Without Private Keys in Hardhat Tests
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Mocking Addresses Without Private Keys in Hardhat Tests

**[Coins Bench](https://daily.dev/sources/coinsbench)** · 1 min read · 2 upvotes · 0 comments

## Summary

Learn how to test smart contracts without the private key for an address using Hardhat's impersonate account mechanism. Verify access control and test interaction between contracts.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://coinsbench.com/mocking-addresses-without-private-keys-in-hardhat-tests-de35f960090a>

---

Tags: [#testing](https://daily.dev/tags/testing), [#ethereum](https://daily.dev/tags/ethereum), [#smart-contracts](https://daily.dev/tags/smart-contracts), [#hardhat](https://daily.dev/tags/hardhat)

[View this post on daily.dev](https://daily.dev/posts/mocking-addresses-without-private-keys-in-hardhat-tests-ez5q1pwui)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Mocking Addresses Without Private Keys in Hardhat Tests","url":"https://daily.dev/posts/mocking-addresses-without-private-keys-in-hardhat-tests-ez5q1pwui","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/mocking-addresses-without-private-keys-in-hardhat-tests-ez5q1pwui"},"datePublished":"2024-04-20T14:27:41.278Z","dateModified":"2024-05-09T09:09:48.658Z","description":"Learn how to test smart contracts without the private key for an address using Hardhat's impersonate account mechanism. Verify access control and test...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/6b87a68188214dce86f272e75db27c3c?_a=AQAEufR","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/6b87a68188214dce86f272e75db27c3c?_a=AQAEufR","isAccessibleForFree":true,"articleSection":"Coins Bench","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Coins Bench","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/ba340d3c8caa4c2586911332928e24d9","url":"https://daily.dev/sources/coinsbench"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/mocking-addresses-without-private-keys-in-hardhat-tests-ez5q1pwui","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"testing,ethereum,smart-contracts,hardhat","timeRequired":"PT1M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Coins Bench","item":"https://daily.dev/sources/coinsbench"},{"@type":"ListItem","position":3,"name":"Mocking Addresses Without Private Keys in Hardhat Tests"}]}
```

