I'm trying to create a transaction (created with populateTransaction), and sign it offchain (the above result, passed as a parameter to signTransaction), but it seems it produces an invalid signature (you can see in the logs below), when I send it for ecrecover.

    // acc1, acc2 should sign the kickout method
    const acc1UnsignedTx = await vendor
      .populateTransaction.kickout(acc3, tokensToStake);

    const acc1Wallet = getWalletForIndex(0);
    const acc1KickoutSignature = await acc1Wallet.signTransaction(

    // acc 2
    const acc2UnsignedTx = await vendor
      .populateTransaction.kickout(acc3, tokensToStake);

    const acc2Wallet = getWalletForIndex(1);
    const acc2KickoutSignature = await acc2Wallet.signTransaction(

    console.log('acc2 unsigned tx ', acc2UnsignedTx)
    console.log("acc2 signature ", acc2KickoutSignature)

    // one of them call executeTransaction
    const nonceBefore = await vendor.nonce();
    await vendor.executeMultiSigTx(
      acc1UnsignedTx.value || 0,
      [acc1KickoutSignature, acc2KickoutSignature]

const getWalletForIndex = (index: any) => {
    return Wallet.fromMnemonic(
      'test test test test test test test test test test test junk',

but I get

acc2 unsigned tx  {
  data: '0x512febdc0000000000000000000000003c44cdddb6a900fa2b585dd299e03d12fa4293bc00000000000000000000000000000000000000000000000ad78ebc5ac6200000',
  to: '0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',
  from: '0x70997970C51812dc3A010C7d01b50e0d17dc79C8',
  gasLimit: BigNumber { _hex: '0x01badbd8', _isBigNumber: true }
acc2 signature  0xf8a680808401badbd894e7f1725e7734ce288f8367e1bb143e90bb3f051280b844512febdc0000000000000000000000003c44cdddb6a900fa2b585dd299e03d12fa4293bc00000000000000000000000000000000000000000000000ad78ebc5ac62000001ca0093579b23a74a1cd1d27956e2673ee70afe46e23792211e324bde43c72ea3a4ca06cd521fc22d17326e22285bcde455041ca83a1253d1f8d381aabfa281d426ed3
    1) should kickout through execute when required # of signatures are collected

  0 passing (1s)
  1 failing

  1) Vendor
       should kickout through execute when required # of signatures are collected:
     Error: VM Exception while processing transaction: reverted with reason string 'ECDSA: invalid signature length'

What am I doing wrong with the creation of the signature ? Why is it such a long string(338 length) ?

1 Answer 1


The value returned by signTransaction is a RLP-encoded raw Ethereum transaction including the signature.

For more info see:

  • I don't understand how to proceed in order to make it work. I've read that I should encode once more the RLP-encoded result to produce a valid signature but I can't make it work. Am I missing something ?
    – gneric
    Jan 28, 2022 at 21:01
  • You need to decode the returned payload. E.g. with docs.ethers.io/v5/api/utils/encoding/#rlp--methods
    – Richard
    Jan 28, 2022 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.