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
.connect(acc1)
.populateTransaction.kickout(acc3, tokensToStake);
const acc1Wallet = getWalletForIndex(0);
const acc1KickoutSignature = await acc1Wallet.signTransaction(
acc1UnsignedTx
);
// acc 2
const acc2UnsignedTx = await vendor
.connect(acc2)
.populateTransaction.kickout(acc3, tokensToStake);
const acc2Wallet = getWalletForIndex(1);
const acc2KickoutSignature = await acc2Wallet.signTransaction(
acc2UnsignedTx
);
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.to!,
acc1UnsignedTx.value || 0,
acc1UnsignedTx.data!,
[acc1KickoutSignature, acc2KickoutSignature]
);
const getWalletForIndex = (index: any) => {
return Wallet.fromMnemonic(
'test test test test test test test test test test test junk',
`m/44'/60'/0'/0/${index}`
);
};
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) ?