pragma cashscript ^0.8.1; // // ** AUTOMATICALLY GENEREATED ** see: phi/script/divide.v2.js // // This is an experimental divider contract // Splits input across a range of predetermined outputs // Beta stage contract Divide( // allowance for party executing the contract int executorAllowance, // number of outputs receiving payout int divisor, // for each beneficiary, take the LockingBytecode as input bytes r0LockingBytecode, bytes r1LockingBytecode ) { function execute() { // distributes to each output in order require(tx.outputs[0].lockingBytecode == r0LockingBytecode); require(tx.outputs[1].lockingBytecode == r1LockingBytecode); // Limit to a single utxo input require(tx.inputs.length == 1); // Get the value of the input int currentValue = tx.inputs[this.activeInputIndex].value; // Value paid to beneficiaries, minus executor allowance int distributedValue = currentValue - executorAllowance; // Value paid to each beneficiary int distribution = distributedValue / divisor; // each output must be greater or equal to the distribution amount require(tx.outputs[0].value >= distribution); require(tx.outputs[1].value >= distribution); } }