# Hardhat testing contracts with swaps

**URL:** <https://forum.openzeppelin.com/t/hardhat-testing-contracts-with-swaps/19704>\
**Category:** Smart Contracts\
**Tags:** erc20, test-environment, hardhat, bep20\
**Created:** [November 25, 2021, 9:03pm UTC](https://forum.openzeppelin.com/t/hardhat-testing-contracts-with-swaps/19704 "2021-11-25T21:03:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ched](https://avatars.discourse-cdn.com/v4/letter/c/b5e925/32.png) [@Ched](https://forum.openzeppelin.com/u/Ched)\
**Post date:** [November 25, 2021, 9:03pm UTC](https://forum.openzeppelin.com/t/hardhat-testing-contracts-with-swaps/19704/1 "2021-11-25T21:03:18Z")

</div>

Hello.  
Someone can share some example of hardhat testing contracts with swaps on dexes like pcs?

Glad to see something with creating LP and swaps from two or more wallets.  
But at least good to see any swap transaction with dex example with two different wallets.  
Thanks for any help.

---

<div class="post-metadata">

**Author:** ![Skyge](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/skyge/32/343_2.png) [@Skyge](https://forum.openzeppelin.com/u/Skyge)\
**Post date:** [December 2, 2021, 2:05am UTC](https://forum.openzeppelin.com/t/hardhat-testing-contracts-with-swaps/19704/2 "2021-12-02T02:05:58Z")

</div>

Actually, `hardhat` integrates the `ethers.js`, if you want to use different addresses to call a function, you can write like this:

```auto
ERC20.connect(Signer1).mint(to, amount);
ERC20.connect(Signer2).mint(to, amount);

```

For more details, maybe you can have a look at the documentation of the `Ethers.js`

> **[Example: ERC-20 Contract](https://docs.ethers.io/v5/api/contract/example/#example-erc-20-contract--methods)**
>
> Documentation for ethers, a complete, tiny and simple Ethereum library.

---

<div class="post-metadata">

**Author:** ![Skyge](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/skyge/32/343_2.png) [@Skyge](https://forum.openzeppelin.com/u/Skyge)\
**Post date:** [December 12, 2021, 2:28pm UTC](https://forum.openzeppelin.com/t/hardhat-testing-contracts-with-swaps/19704/4 "2021-12-12T14:28:36Z")

</div>

Maybe you can select a framework at first, and then check the documentation of it.  
OpenZeppelin also has some test case, you can have a look.

---

<div class="post-metadata">

**Author:** ![Skyge](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/skyge/32/343_2.png) [@Skyge](https://forum.openzeppelin.com/u/Skyge)\
**Post date:** [December 13, 2021, 1:01am UTC](https://forum.openzeppelin.com/t/hardhat-testing-contracts-with-swaps/19704/6 "2021-12-13T01:01:56Z")

</div>

Emmmm, I think you can look through other people's code and try to write the code by yourself and then try to update again and again, then you will get the `good wrote code`

---

<div class="post-metadata">

**Author:** ![Ched](https://avatars.discourse-cdn.com/v4/letter/c/b5e925/32.png) [@Ched](https://forum.openzeppelin.com/u/Ched)\
**Post date:** [December 13, 2021, 5:28pm UTC](https://forum.openzeppelin.com/t/hardhat-testing-contracts-with-swaps/19704/7 "2021-12-13T17:28:06Z")

</div>

yeah, its basic way bro  
i want to make it faster, this is why i ask about it here.
