// make sure balance in the contract does not change
const amount: bigint = this.ctx.utxo.value
// output containing the latest state
const output: ByteString = this.buildStateOutput(amount)
// verify current tx has this single output
assert(this.ctx.hashOutputs == hash256(output), 'hashOutputs mismatch')
Make it easier to understand. https://github.com/sCrypt-Inc/scryptTS-examples/blob/8d8de7e0b244e2009c9cffefa43699c788622791/src/contracts/counter.ts#L30-L36
Change to https://scrypt.io/scrypt-ts/tutorials/stateful-contract#update-states