Ethers.JS: convert an HDNodeWallet to a SignerWithAddress from Hardhat

42 views Asked by At

I'm testing my dApp... I wish to use randomly generated wallets to perform operations on my contracts, including transfers (sendTransaction({})) The 20 SignerWithAddress coming with HardHat are not sufficient. I want more.

So I tried ethers.Wallet.createRandom() which creates a HDNodeWallet type object. Unfortunately.this type cannot perform unchecked transactions: Error: missing provider (operation="sendTransaction", code=UNSUPPORTED_OPERATION, version=6.11.0)

Now either I adapt my transactions to be "checked" or I need a way to convert a HDNodeWallet to a SignerWithAddress type.

This is the transfer function:

await holderSigner.sendTransaction({
    to: randomGeneratedUsers[i].address,
    value: ethers.parseUnits('10', 'ether'),
});

These are the missing methods:

Argument of type 'HDNodeWallet' is not assignable to parameter of type 'HardhatEthersSigner'.
Type 'HDNodeWallet' is missing the following properties from type 'HardhatEthersSigner':
toJSON, _sendUncheckedTransactionts (2345)

Ideas?

0

There are 0 answers