Home Crypto Solidity Ether.js VoidSigner cannot sign transactions fix

Solidity Ether.js VoidSigner cannot sign transactions fix

0
Solidity Ether.js VoidSigner cannot sign transactions fix

[ad_1]

One of the most common and confusing issues you might fall into while working on testing solidity contracts using Ethere.js on Hardhat is:

Error: VoidSigner cannot sign transactions (operation=”signTransaction”, code=UNSUPPORTED_OPERATION, version=abstract-signer/5.7.0)

It means that the current transaction you are trying to execute cannot be signed, because the signer you provided is a VoidSigner.

A VoidSigner according to the Ethers.js documentation is:

a simple Signer which cannot sign.

Essentially it’s only valid for read-only operations. If the operation you’re trying to execute changes some data, then it will fail with the above error.

Let’s say we have a contract called Foo.sol:

And the test for that contract looks like the following:

If we run this test we will get the following error:

Error: VoidSigner cannot sign transactions (operation=”signTransaction”, code=UNSUPPORTED_OPERATION, version=abstract-signer/5.7.0)

By default, when passing an address as a String, it’s considered a VoidSigner, hence why we get the error.

Instead of passing a VoidSigner, we’ll need to pass a Signer instance.

I hope you find this article useful!

Give it some claps to make others find it too! Make sure you follow me on Medium not to miss anything.

If you like short and simple articles filled with great tips and new tools consider subscribing to my newsletter:

http://eepurl.com/iaBAyj

http://eepurl.com/iaBAyj

New to trading? Try crypto trading bots or copy trading

[ad_2]

Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here