pragma cashscript >= 0.7.0; // // ** AUTOMATICALLY GENEREATED ** see: phi/script/divide.v1.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, bytes r2LockingBytecode ) { function execute() { // distributes to each output in order require(tx.outputs[0].lockingBytecode == r0LockingBytecode); require(tx.outputs[1].lockingBytecode == r1LockingBytecode); require(tx.outputs[2].lockingBytecode == r2LockingBytecode); // Get the total value of inputs int currentValue = tx.inputs[this.activeInputIndex].value; // Total 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); require(tx.outputs[2].value >= distribution); } }