I am doing raw signing for evm chain not yet supported by Fireblock, for that I am creating a txn object, serializing it and sending to Fireblock for signing it then broadcasting the txn onchain. But facing wrong format transaction error on broadcast.
try {
const amountToSend = web3_imx.utils.toWei('0.001', 'ether');
const txObject = {
to: "0x3ED87449591524deF3A2f9aeA247dcD3BD38687f",
value: web3_imx.utils.toHex(amountToSend),
gasLimit: web3_imx.utils.toHex(21000),
};
const common = Common.custom({ chainId: 11155111 })
const tx = LegacyTransaction.fromTxData(txObject, { common })
const serializedTx = tx.serialize();
const content = Buffer.from(serializedTx).toString("hex")
const payload = {
assetId: "ETH_TEST5",
operation: TransactionOperation.RAW,
source: {
type: PeerType.VAULT_ACCOUNT,
id: "0"
},
note: ``,
extraParameters: {
rawMessageData: {
messages: [
{
content,
}
]
},
}
};
var { id, status } = await fireblocks.createTransaction(payload);
// txn fails here and I am getting : Unsupported length
//The raw signing transaction contains at least one message of length different than 32 bytes.
// Fireblocks does not allow a message with a different length for this encryption protocol.
let txInfo = await fireblocks.getTransactionById(id);
console.log("txn Info signs = ", txInfo.signedMessages[0].signature);
// GETTING txn Info signs = {
// r: '63cc5815885fe50bb488452b669df770cc879b273d11990541dead0f79aca21d',
// s: '2ec895f26d7d527758b27b190ca517c7ebd5a63f30516d2a79b236acb1e6d931',
// v: 0,
// fullSig: '63cc5815885fe50bb488452b669df770cc879b273d11990541dead0f79aca21d2ec895f26d7d527758b27b190ca517c7ebd5a63f30516d2a79b236acb1e6d931'
// }
// I should get something like this:
// {
// v: ‘0x6966’,
// r: ‘0x9e6997a8de413e66777fb482234be3c4e764510588dd9790b5f06dfa93c4b2b5’,
// s: ‘0x9450d11d2037ab2a3e5efc246b5d316a835280b98947009ad8eb5387f1f1985’,
// rawTransaction: ‘0xf86e0c8502540be43182520894d7b126d15d3d158df7a7a90040f5839567c0932088016345785d8a000080826966a09e6997a8de413e66777fb482234be3c4e764510588dd9790b5f06dfa93c4b2b5a009450d11d2037ab2a3e5efc246b5d316a835280b98947009ad8eb5387f1f1985’,
// }
broadcastTransaction(txInfo.signedMessages[0].signature)
.then(async (receipt) => {
const tx = await web3_imx.eth.getTransaction(receipt.transactionHash);
console.log('Transaction details:', tx);
const status = await web3_imx.eth.getTransactionReceipt(receipt.transactionHash);
console.log('Transaction receipt status:', status.status);
})
async function broadcastTransaction(signature) {
const { r, s, v, fullSig } = signature;
const encodedSig = Buffer.from([Number.parseInt(signature.v, 16) + 31]).toString("hex") + signature.fullSig;
console.log("Encoded Signature:", Buffer.from(encodedSig, "hex").toString("base64"));
// Encoded Signature: H2PMWBWIX+ULtIhFK2ad93DMh5snPRGZBUHerQ95rKIdLsiV8m19UndYsnsZDKUXx+vVpj8wUW0qebI2rLHm2TE=
const encode_sig = Buffer.from(encodedSig, "hex").toString("base64")
const receipt = await web3_imx.eth.sendSignedTransaction(encode_sig);
return receipt;
}