It’s wrapping season , and I made a simple contract to wrap BCH. It’s also online for testing at https://wrapped.cash
pragma cashscript ^0.9.0;
// Wrap BCH as tokens
//
// Transaction form:
// Inputs: 00-covenant
// Outputs: 00-covenant
//
// Author: Dagur Valberg Johannsson <dagurval@pvv.ntnu.no>
// License: MIT
contract WrapBCH() {
function wrapOrUnwrap() {
// Enforce that this contract lives on
require(tx.outputs[this.activeInputIndex].lockingBytecode
== tx.inputs[this.activeInputIndex].lockingBytecode);
require(tx.outputs[this.activeInputIndex].tokenCategory
== tx.inputs[this.activeInputIndex].tokenCategory);
require(tx.inputs[this.activeInputIndex].tokenAmount + tx.inputs[this.activeInputIndex].value
== tx.outputs[this.activeInputIndex].tokenAmount + tx.outputs[this.activeInputIndex].value);
}
}
I’m looking for review of any possible issues with it
edit: The contract has been deployed in address p0ujgnc9jnyurzv99678fgac3fdrq8x3py9rlrg6dlnz96qxrdl02efwc0sf