# 12.8 Export the definition

The machine is data, so it can be exported: a JSON description of every state, event, guard and
reduction. The browser's copy of the machine in Part 6 is generated from it, and a corpus of sample
inputs, from `Differential`, says what the machine should do with each. Both are generated by the
`trax` tool and committed, so a change to the machine shows up in review as a change to them.

Install the tool for the solution:

```bash
dotnet new tool-manifest
dotnet tool install Trax.Cli --version 1.61.0
```

Build the library, then export:

```bash
dotnet build Shopfront.Core
dotnet trax machine generate --assembly Shopfront.Core/bin/Debug/net10.0/Shopfront.Core.dll \
  --machine Shopfront.Machines.Checkout.CheckoutMachine \
  --ir-out machines/checkout --corpus-out machines/checkout
```

```text
  ir        machines/checkout/checkout.ir.json
  corpus    machines/checkout/differential.json
Generated 2 artifact(s) for 'checkout'.
```

The corpus is worked out by running each sample through the reference engine, the TypeScript one
the browser will use, so `generate` needs Node.js 22 or later on the path. Build the library again
afterwards, so it embeds the corpus it was just given.

`dotnet trax machine check`, with the same arguments, fails when the committed files no longer
match the machine. It belongs in CI.

```text
  ok      ir        machines/checkout/checkout.ir.json
  ok      corpus    machines/checkout/differential.json
All artifacts for 'checkout' are up to date.
```

## SDK Reference

> [Machine](/docs/sdk-reference/statemachine-api/machine) | [Rules](/docs/sdk-reference/statemachine-api/rules) | [AddStateMachines](/docs/sdk-reference/statemachine-api/add-state-machines) | [Machines over GraphQL](/docs/sdk-reference/graphql-api/machines) | [UsePersistedOperations](/docs/sdk-reference/persisted-operations/use-persisted-operations) | [trax CLI](/docs/reference/cli)

---

Next: [12.9 Test it](/docs/book/checkout-is-a-state-machine/test-it)
