I’m trying to sign a simple transaction with ethers.js and my hardward wallet. The code is fine since it’s work well on ethereum mainnet, Binance Smart Chain and Fantom. But when I use this code to sign a transaction on Polygon I got the following error : Error: transaction.chainId/signature.v mismatch (argument="signature", value={"v":54,"r":"...","s":"..."}, code=INVALID_ARGUMENT, version=transactions/5.6.2)
Minimum code to reproduce:
const provider = new ethers.providers.WebSocketProvider('wss://....'); const signer = new LedgerSigner(provider, 'hid'); const chainId = (await provider.getNetwork()).chainId; await signer.signTransaction({ from: await signer.getAddress(), to: '0x....', value: '1000000000000000000', gasLimit: 21000, chainId: chainId, nonce: await signer.getTransactionCount('latest'), gasPrice: 100000000000, });
I really doesn’t understand why. Note that I’ve triple check that’s the provider is the good one and the chainId is 137.
Thanks for help.