sCrypt-Inc / scryptTS-examples

Examples of using scryptTS
https://scrypt.io/scryptTS
11 stars 5 forks source link

Simplify counter #34

Closed xhliu closed 1 year ago

xhliu commented 1 year ago

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

// 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')