I am testing the correct emission of NFTMintedAll event on the following function, using hardhat:

    event NFTMintedAll(
        uint256 requestId,
        address indexed owner,
        uint256[] randomWords,
        uint256 amount,
        address[] indexed variants,
        uint256[] indexed tokenIds

    function requestNFTs(
        address _variant,
        uint256 _variantType,
        uint256 _amount,
        address _paymentToken
    ) external {

        uint256[] memory noRandomWords = new uint256[](0);
        uint256[] memory allTokenIds = new uint256[](_amount);
        address[] memory allVariants = new address[](_amount);

        for (uint256 index = 0; index < _amount; index++) {
            allVariants[index] = address(_variant);
            GMG_ERC721_BaseInterface variant = GMG_ERC721_BaseInterface(_variant);
            require(variant.getRandom() == false, "Variant only available as random mint");
            require(getVariantRemainingSupply(address(variant)) >= 1);
            uint256 tokenCost = variant.getTokenCost(_paymentToken);
            require(tokenCost > 0, "Token cost not set");
            address checkoutWallet = variant.getCheckoutWallet();
            require(checkoutWallet != address(0), "Checkout wallet not set");
            IERC20 token = IERC20(_paymentToken);
            uint256 mintedId = variant.mintType(msg.sender, _variantType);
            allTokenIds[index] = mintedId;

        emit NFTMintedAll(0, msg.sender, noRandomWords, _amount, allVariants, allTokenIds);


The problem I am having is that the following code is not failing...

                await expect(hardhatMintManager.requestNFTs(
                )).to.emit(hardhatMintManager, "NFTMintedAll").withArgs(

...meaning that allVariants and allTokenIds arrays are always empty.

Why these array seem to be empty when the event gets emitted?

1 Answer 1


The indexed parameters of events are not stored directly in the event logs. Instead, the Keccak-256 hashes of these parameters are stored. This is particularly relevant for dynamic types like arrays.

In your NFTMintedAll event, you have declared both variants and tokenIds as indexed. Since these are arrays, they cannot be efficiently indexed directly due to their dynamic nature. EVM does not support indexing of dynamic types (like arrays) directly in a way that you can retrieve their original values through event logs.

By removing the indexed keyword from variants and tokenIds, you will be able to capture and assert the entire arrays' contents in your Hardhat tests.

Your Answer

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

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