hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

Hardhat Support for eth_signTransaction

Open jiaochangyang opened this issue 2 years ago • 6 comments

Hardhat node does not currently have support for eth_signTransaction, which is defined in the Ethereum JSON-RPC specifications. It would be good to have this particular feature for dApp development purposes as it would allow for simpler unit-testing through unlocked accounts, while still handling raw transaction submission the same way.

jiaochangyang avatar Aug 18 '22 16:08 jiaochangyang

This issue is also being tracked on Linear.

We use Linear to manage our development process, but we keep the conversations on Github.

LINEAR-ID: 9a131121-a6a9-4b7f-a2d6-dee349232fdc

github-actions[bot] avatar Aug 18 '22 16:08 github-actions[bot]

Should the required functionality not be similar to the current implementation of eth_sendTransactionAction in packages/hardhat-core/src/internal/hardhat-network/provider/modules/eth.ts? Just replacing the this._sendTransactionAndReturnHash(tx) source code line of sendTransaction at the end of the function by tx as shown in the screenshot below. image

sisco0 avatar Sep 19 '22 06:09 sisco0

I believe you are right that this functionality does what is requested. Would it be possible to expose this as a public functionality?

jiaochangyang avatar Sep 28 '22 01:09 jiaochangyang

Any chance of this getting picked up?

jiaochangyang avatar Dec 11 '23 15:12 jiaochangyang

I'm not (in principle) against implementing this; we've just had other priorities. Also, no one else seems to be asking for this to be implemented (it's not a very commonly used method AFAIK; you normally send the transaction and your library, wallet or node handles it).

Maybe having specific use cases that are not possible right now would help us prioritize this.

fvictorio avatar Dec 22 '23 10:12 fvictorio

Ah I was just bitten by this trying to use signTransaction from a client provided by hardhat-viem and was getting unknown account. A bit surprising when sendTransaction and signMessage were working fine.

My use case was signing an approval + swap manually, with precise control of the nonce. But I guess I can just use sendTransaction for now.

jeanregisser avatar Mar 28 '24 11:03 jeanregisser