[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [local‑first/Protocol](https://evolu.dev/docs/api-reference/common/local-first/Protocol) › createProtocolUploadFromCrdtMessages

```ts
function createProtocolUploadFromCrdtMessages(
  deps: RandomBytesDep & XChaCha20Poly1305Dep,
): (
  owner: Owner,
  messages: readonly [CrdtMessage, CrdtMessage],
  maxSize?: number &
    Brand<"NonNaN"> &
    Brand<"Finite"> &
    Brand<"Int"> &
    Brand<"Between1000000-100000000">,
) => ProtocolUpload;
```

Defined in: [packages/common/src/local-first/Protocol.ts:656](https://github.com/evoluhq/evolu/blob/4eedb2272841bdeb2d7c3387784ba157d2f33f1c/packages/common/src/local-first/Protocol.ts#L656)

Creates the [ProtocolUpload](https://evolu.dev/docs/api-reference/common/local-first/Protocol/interfaces/ProtocolUpload) of CRDT messages.

The message holds the leading CRDT messages that fit `maxSize`, by default
[defaultProtocolMessageMaxSize](https://evolu.dev/docs/api-reference/common/local-first/Protocol/variables/defaultProtocolMessageMaxSize), measured exactly. When one does not
fit, it and the rest are left out, and the message ends with a range that
makes the non-initiator answer with ranges. Sync then sends them in later
rounds, even over unidirectional and stateless transports, because every
change within [maxMutationSize](https://evolu.dev/docs/api-reference/common/local-first/Evolu/variables/maxMutationSize) fits an empty message. `isComplete`
tells whether the message holds every CRDT message, so its sender knows
whether only its later rounds send the rest.

### Example

```ts
import {
  assertSame,
  createId,
  createXChaCha20Poly1305,
  testCreateDeps,
} from "@evolu/common";
import {
  createProtocolUploadFromCrdtMessages,
  testAppOwner,
  testCreateCrdtMessage,
} from "@evolu/common/local-first";

const deps = {
  ...testCreateDeps(),
  xChaCha20Poly1305: createXChaCha20Poly1305(),
};
const upload = createProtocolUploadFromCrdtMessages(deps)(testAppOwner, [
  testCreateCrdtMessage(createId(deps), 1, "Ada"),
]);
assertSame(upload.isComplete, true);
```