def serialize(self) -> bytes:
        ms = StreamManager.GetStream()
        writer = BinaryWriter(ms)
        writer.WriteBytes(self.serialize_unsigned())
        writer.WriteVarInt(len(self.sigs))

        for sig in self.sigs:
            writer.WriteBytes(sig.serialize())

        ms.flush()
        temp = ms.ToArray()
        StreamManager.ReleaseStream(ms)
        return a2b_hex(temp)
 def serialize_unsigned(self) -> bytes:
     ms = StreamManager.GetStream()
     writer = BinaryWriter(ms)
     writer.WriteUInt8(self.version)
     writer.WriteUInt8(self.tx_type)
     writer.WriteUInt32(self.nonce)
     writer.WriteUInt64(self.gas_price)
     writer.WriteUInt64(self.gas_limit)
     writer.WriteBytes(bytes(self.payer))
     writer.WriteVarBytes(bytes(self.payload))
     writer.WriteVarInt(len(self.attributes))
     ms.flush()
     res = ms.ToArray()
     StreamManager.ReleaseStream(ms)
     return res