Contract Debugging – How to Use changeEtherBalance from Waffle-Hardhat

contract-debuggingethers.jshardhattestwaffle

I want to check if the ether balance of an account decreased after the transaction using changeEtherBalance I tried to follow the waffle docs but couldn't do it either.

        await token.connect(addr1).mint(1, {value: ethers.utils.parseEther("0.1")}))
        .to.changeEtherBalance(addr1, -(ethers.utils.parseEther("0.1"))
        );

Error:

Error: overflow (fault="overflow", operation="BigNumber.from", value=-100000000000000000, code=NUMERIC_FAULT, version=bignumber/5.5.0)

Best Answer

You can see more information here. Basically you should send the recipient and the amount:

await expect(() => wallet.sendTransaction({to: walletTo.address, value: 200}))
  .to.changeEtherBalance(walletTo, 200);
Related Topic