# Function: writeMetabolicState()

[**lifecycle-kit**](https://jonbogaty.com/lifecycle-kit/api/readme/index.md)

***

[lifecycle-kit](https://jonbogaty.com/lifecycle-kit/api/readme/index.md) / [chem](https://jonbogaty.com/lifecycle-kit/api/chem/readme/index.md) / writeMetabolicState


# Function: writeMetabolicState() {#function-writemetabolicstate}


> **writeMetabolicState**(`state`): `string`

Defined in: [chem/metabolism.ts:312](https://github.com/jbcom/lifecycle-kit/blob/074e4e7b8038d3e2de9eb44c4b5b5aee0ef02b48/src/chem/metabolism.ts#L312)

Serialise a validated, canonical metabolic state for persistence.

Reads are forgiving because storage can be old or corrupt. Writes reject a
bad state instead: persisting a NaN as JSON `null` would make the corruption
durable and erase the argument name that caused it.


## Parameters {#parameters}



### state {#state}


[`MetabolicState`](https://jonbogaty.com/lifecycle-kit/api/chem/interfaces/metabolicstate/index.md)


## Returns {#returns}


`string`
