Examples & Use-cases
Address Examples & Use-cases
A collection of useful Addresses to bootstrap your Nexa "wise" contract(s).
For Beginners
Address language is often intimidating at first, so we plan to ease you in ... gently.
pragma nexscript >= 0.2.0;
contract Oddity() {
/**
* Transfer
*
* An asset transfer is permitted ONLY when the number of recipients
* is ODD.
*/
function transfer() {
/* Set (total) number of (transaction) outputs. */
int numOutputs = tx.outputs.length;
/* Calculate oddity flag. */
int isOddity = numOutputs % 2;
/* Validate oddity flag. */
// NOTE: An even number of outputs, eg. Two (2) or Four (4)
// will automatically FAIL!
require(isOddity == 1);
}
}
You should know!
NexAddress offers a very user-friendly JavaAddress-style programming language that is very similar to Solidity.