I am testing my contract using Waffle and I am following the documentation provided, using const provider = new MockProvider(); to get a provider for testing.

An error was raised in expect().catch() and it says that "Provider not found". Before trying to catch it, I had a more annoying warning that told me to handle errors and this is what I get after handling them.

Everything seems to work as expected but I would like to get rid of this stuff.

I let my code bellow

it("Shall fund the contract", async () => 
        const contract = await deployContract() 
        const address = "0x5FbDB2315678afecb367f032d93F642f64180aa3";
        const provider = new MockProvider();
        const [wallet, otherWallet] = provider.getWallets();
        tx = {
          to: address,
          value: utils.parseEther("3.0")
        await wallet.signTransaction(tx);
        const walletTo = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266";
        expect(await wallet.sendTransaction(tx)).to.changeEtherBalance(walletTo, 3)
        .catch((err) => 

1 Answer 1


changeEtherBalance expects a contract or a signer rather than a string. If you are checking if the contract is funded, then rather than a hardcoded address, use contrat.address. You can then pass contract into the changeEtherBalance

const address = contract.address;
// Send to address....
changeEtherBalance(contract, ....

If you don't care about the to address and any random address works for the purposes of the test, then you can use:

const walletTo = provider.createEmptyWallet();
const address = walletTo.address;

If you want to use that specific address, it seem slike changeEtherBalance expects, as an API, a signer or contract interface. You would need the private key or mnemonic and call:

const walletTo = new ethers.Wallet(privKey, provider);
const address = walletTo.address;

Optionally, you can just rewrite your test to call

const newBalance = await provider.getBalanceOf(walletTo);

And use a normal math expect.

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.