question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using a `SignerWithAddress` to sign a transaction from `populateTransaction` fails with "Signing transactions is unsupported"

See original GitHub issue

Describe the bug

I am creating an unsigned transaction with contractMethod.populateTransaction.method() then signing with signer.SignTransaction(unsignedTransaction)

The second step fails with

  reason: 'signing transactions is unsupported',
  code: 'UNSUPPORTED_OPERATION',
  operation: 'signTransaction'

Reproduction steps

  const MyContract = await ethers.getContractFactory('MyContract')
  const signers = await ethers.getSigners()
  const admin = signers[0]
  

  
  const myContract = (await MyContract.attach(myContractAddress)) as MyContract
  
  const unlockTransaction = await myContract.populateTransaction.testMethod(true, {nonce: firstNonce})
  const unlockTransactionSigned = await admin.signTransaction(unlockTransaction)

Environment: Node v14 Goerli

Search Terms Ethers Sign raw transaction

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
ricmoocommented, Jan 25, 2022

Correct. It exists because it sub-classes Signer, but if the client doesn’t support it, it will throw an error when it is attempted to be used.

1reaction
ricmoocommented, Jan 25, 2022

That is a JsonRpcSigner instance, not a Wallet instance. So it depends on what Provider you are using, but most providers you need a Web3Provider for will not support signing a transaction as it is a security and UX concern. That’s nothing to do with ethers, that is the client deciding to not allowing signing transactions (for good reasons).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Signers - ethers
This method populates the transactionRequest with missing fields, using populateTransaction and returns a Promise which resolves to the transaction. Sub-classes ...
Read more >
Signing a request with a signature gives the wrong from address
You don't sign a request with a signature, you sign a transaction. You cannot generate generic signatures to be associated to transactions ......
Read more >
Cannot switch signers with ethers.js for a contract interaction ...
The error you get is because you are not passing in the full address object. Specifically, I get your exact error when I...
Read more >
ethers-io/Lobby - Gitter
Hello. I need to write in contract with walletconnect provider, but it says that there's no method eth_sendTransaction. I need to sign it...
Read more >
Signing transactions with web3 or ethers? How does it even ...
Again ether.js returns the following error: Error: signing transactions is unsupported (operation="signTransaction", code=UNSUPPORTED_OPERATION, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found