internal override byte[] GenerateBytes()
        {
            var builder = new FlatBufferBuilder(1);

            // create message
            var bytePayload = Message.GetPayload();
            var payload     = MessageBuffer.CreatePayloadVector(builder, bytePayload);

            MessageBuffer.StartMessageBuffer(builder);
            MessageBuffer.AddType(builder, Message.GetMessageType());
            MessageBuffer.AddPayload(builder, payload);
            var messageVector = MessageBuffer.EndMessageBuffer(builder);

            // create mosaics
            var mosaicBuffers = new Offset <MosaicBuffer> [Mosaics.Count];

            for (var index = 0; index < Mosaics.Count; ++index)
            {
                var mosaic = Mosaics[index];
                var id     = MosaicBuffer.CreateIdVector(builder, mosaic.Id.Id.ToUInt8Array());
                var amount = MosaicBuffer.CreateAmountVector(builder, mosaic.Amount.ToUInt8Array());
                MosaicBuffer.StartMosaicBuffer(builder);
                MosaicBuffer.AddId(builder, id);
                MosaicBuffer.AddAmount(builder, amount);
                mosaicBuffers[index] = MosaicBuffer.EndMosaicBuffer(builder);
            }

            // create recipient
            byte[] recipientBytes = Recipient.GetBytes();

            // create vectors
            var signatureVector = TransferTransactionBuffer.CreateSignatureVector(builder, new byte[64]);
            var signerVector    = TransferTransactionBuffer.CreateSignerVector(builder, GetSigner());
            var deadlineVector  = TransferTransactionBuffer.CreateDeadlineVector(builder, Deadline.Ticks.ToUInt8Array());
            var feeVector       = TransferTransactionBuffer.CreateMaxFeeVector(builder, MaxFee?.ToUInt8Array());
            var recipientVector =
                TransferTransactionBuffer.CreateRecipientVector(builder, recipientBytes);
            var mosaicsVector = TransferTransactionBuffer.CreateMosaicsVector(builder, mosaicBuffers);

            // total size of transaction

            /*var totalSize = HEADER_SIZE
             + 25 // recipient
             + 2 // message size is short
             + 1 // message type byte
             + 1 // no of mosaics
             + ((8 + 8) * Mosaics.Count) //each mosaic has id(8bytes) and amount(8bytes)
             + bytePayload.Length; // number of message bytes*/

            var totalSize = GetSerializedSize();

            // create version
            var version = GetTxVersionSerialization();


            // add vectors
            TransferTransactionBuffer.StartTransferTransactionBuffer(builder);
            TransferTransactionBuffer.AddSize(builder, (uint)totalSize);
            TransferTransactionBuffer.AddSignature(builder, signatureVector);
            TransferTransactionBuffer.AddSigner(builder, signerVector);
            TransferTransactionBuffer.AddVersion(builder, (uint)version);
            TransferTransactionBuffer.AddType(builder, EntityType.TRANSFER.GetValue());
            TransferTransactionBuffer.AddMaxFee(builder, feeVector);
            TransferTransactionBuffer.AddDeadline(builder, deadlineVector);

            TransferTransactionBuffer.AddRecipient(builder, recipientVector);
            TransferTransactionBuffer.AddNumMosaics(builder, (byte)Mosaics.Count);
            TransferTransactionBuffer.AddMessageSize(builder, (ushort)(bytePayload.Length + 1));
            TransferTransactionBuffer.AddMessage(builder, messageVector);
            TransferTransactionBuffer.AddMosaics(builder, mosaicsVector);

            // end build
            var codedTransfer = TransferTransactionBuffer.EndTransferTransactionBuffer(builder);

            builder.Finish(codedTransfer.Value);

            // validate size
            var output = new TransferTransactionSchema().Serialize(builder.SizedByteArray());

            if (output.Length != totalSize)
            {
                throw new SerializationException("Serialized form has incorrect length");
            }

            return(output);
        }