# expectEvent not working with hardhat

**URL:** <https://forum.openzeppelin.com/t/expectevent-not-working-with-hardhat/28167>\
**Category:** Smart Contracts\
**Created:** [April 29, 2022, 8:38am UTC](https://forum.openzeppelin.com/t/expectevent-not-working-with-hardhat/28167 "2022-04-29T08:38:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SalvatoreCataniaVS](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/salvatorecataniavs/32/12921_2.png) [@SalvatoreCataniaVS](https://forum.openzeppelin.com/u/SalvatoreCataniaVS)\
**Post date:** [April 29, 2022, 8:38am UTC](https://forum.openzeppelin.com/t/expectevent-not-working-with-hardhat/28167/1 "2022-04-29T08:38:14Z")

</div>

Hi, I'm trying to test events from my smart contract, but seems that in not able to recognize transaction receipt object in hardhat.

This is my event:

```auto
event AccessTokenPurchased (
        string channelId,
        address indexed buyer
    );

```

And this is my test:

```auto
const receiptPurchase = await accessTokenManager.connect(buyer).purchase(channelId, {value: ethers.utils.parseUnits((price + buyerFee).toString(), 'ether')})

expectEvent(receiptPurchase, 'AccessTokenPurchased', {
                             channelId: channelId,
                             buyer: buyer.address
});

```

But I'm getting this error back:  
`Error: Unknown transaction receipt object`

I have already imported all the required library  
**test.js**

```auto
const {
        expectEvent, 
        expectRevert
} = require('@openzeppelin/test-helpers')

```

**hardhat.config.js**  
`require("@nomiclabs/hardhat-truffle5");`

Can someone explain if is possible to test event with hardhat?  
Thanks.
