ethers.js icon indicating copy to clipboard operation
ethers.js copied to clipboard

sendTransaction times out

Open nandlab opened this issue 1 year ago • 3 comments

Ethers Version

5.7.1

Search Terms

transaction signer

Describe the Problem

I am using Remix IDE with the Remix VM (Shanghai) environment.

In a Javascript unit test, I would like to send Ether from the main account to another account, but the sendTransaction() function times out.

Code Snippet

/* eslint-disable no-undef */
// Right click on the script name and hit "Run" to execute
const { expect } = require("chai");
const { ethers } = require("hardhat");

describe("Ether transaction", function () {
  it("test transaction", async function () {
    console.log(ethers.version);
    let [owner] = await ethers.getSigners();
    let balance = (await owner.getBalance()).toBigInt();
    console.log(`Current balance is: ${balance}`);
    let value = ethers.utils.parseEther("1.0");
    expect(balance).to.be.at.least(value);
    let recipient = "<another address>";
    console.log(`Sending some ETH to recipient ${recipient}`);
    await owner.sendTransaction({
        "to": recipient,
        "value": value
    });
    let newBalance = (await owner.getBalance()).toBigInt();
    console.log(`New balance is: ${newBalance}`);
    expect(newBalance - balance).to.be(value);
  });
});

Contract ABI

No response

Errors

✘ test transaction (50738 ms)
  Message: Timeout of 50000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

Environment

Hardhat

Environment (Other)

Remix IDE

nandlab avatar Jan 19 '24 22:01 nandlab

How are you using Remix with ethers? Does it provide an EIP-1193 provider?

Have you tried ethers v6, which has much more flexibility for connecting to exotic environments?

Regardless, in v5 you can decrease the polling interval to increase the speed which the internals operated, scanning for new blocks, which on a test environment should occur quite quickly using provider.pollingInterval = 200 (which will poll every 200ms).

ricmoo avatar Jan 19 '24 22:01 ricmoo

@ricmoo, thank you for the fast reply!

How are you using Remix with ethers? Does it provide an EIP-1193 provider?

I have written the script in tests/transaction.test.js and I am just running it. I don't know if it is an EIP-1193 provider.

Have you tried ethers v6, which has much more flexibility for connecting to exotic environments?

I don't know how to use another version. 5.7.1 is just the default version I get in Remix IDE. Sorry, I am quite new to Ethereum so I am a bit overwhelmed :sweat_smile:

Regardless, in v5 you can decrease the polling interval to increase the speed which the internals operated, scanning for new blocks, which on a test environment should occur quite quickly using provider.pollingInterval = 200 (which will poll every 200ms).

I added the line owner.provider.pollingInterval = 200; after let [owner] = await ethers.getSigners(); but it did not help.

nandlab avatar Jan 19 '24 23:01 nandlab

I have opened an issue on Remix to see if I can help out too. :)

https://github.com/ethereum/remix-project/issues/4479

ricmoo avatar Jan 20 '24 02:01 ricmoo