Transactions

Compute the raw transaction

function getRawTransaction(tx) { function addKey(accum, key) { if (tx[key]) { accum[key] = tx[key]; } return accum; } // Extract the relevant parts of the transaction and signature const txFields = "accessList chainId data gasPrice gasLimit maxFeePerGer maxPriorityFeePerGas nonce to type value".split(" "); const sigFields = "v r s".split(" "); // Seriailze the signed transaction const raw = utils.serializeTransaction(txFields.reduce(addKey, { }), sigFields.reduce(addKey, { })); // Double check things went well if (utils.keccak256(raw) !== tx.hash) { throw new Error("serializing failed!"); } return raw; }