serializeTransaction static method
serialize transaction to bytes
Implementation
static List<int> serializeTransaction(
VersionedMessage message, List<List<int>> signatures) {
final serializedMessage = message.serialize();
final encodedSignaturesLength =
SolanaTransactionUtils._encodeLength(signatures.length);
final transactionLayout = LayoutUtils.struct([
LayoutUtils.blob(encodedSignaturesLength.length,
property: 'encodedSignaturesLength'),
LayoutUtils.array(
LayoutUtils.blob(64, property: "signature"), signatures.length,
property: 'signatures'),
LayoutUtils.blob(serializedMessage.length, property: 'serializedMessage')
]);
final serializedTransaction = LayoutByteWriter.filled(2048);
final serializedTransactionLength = transactionLayout.encode({
'encodedSignaturesLength': encodedSignaturesLength,
'signatures': signatures,
'serializedMessage': serializedMessage
}, serializedTransaction);
return serializedTransaction
.toBytes()
.sublist(0, serializedTransactionLength);
}