|
contract: { |
|
majorVersion: 1, |
|
minorVersion: 0, |
|
triggerType: send; |
|
// stack is [ "EmbeddedAddress" "MSourceAddress", "MDestinationAddress", "MONANA", 1000, "memo" ] |
|
// "EmbeddedAddress" was stored in the contract itself by "clone" contract. |
|
script: [ |
|
// Return period check. |
|
0, |
|
OPX_CURRENTBLOCK, // result: [ ..., 0, 100 ] |
|
OPX_BEGINBLOCK, // result: [ ..., 0, 100, 10 ] |
|
130, // result: [ ..., 0, 100, 10, 130 ] // period |
|
OP_ADD, OP_SUB, // result: [ ..., 0, -40 ] |
|
OP_GREATERTHAN, // result: [ ..., OP_1 ] |
|
OP_VERIFY // result: [ ... ] or fail |
|
|
|
// Source address check. |
|
5, 4, |
|
OP_PICK, OP_PICK, // result [ "EmbeddedAddress", "MSourceAddress", "MDestinationAddress", "MONANA", 1000, "memo", "EmbeddedAddress", "MSourceAddress" ] |
|
OP_EQUALVERIFY, // result: [ "EmbeddedAddress", "MSourceAddress", "MDestinationAddress", "MONANA", 1000, "memo" ] or fail |
|
//// "EmbeddedAddress" can be ignored in following results. |
|
|
|
// Destination address check. |
|
3, |
|
OP_PICK, // result: [ "MSourceAddress", "MDestinationAddress", "MONANA", 1000, "memo", "MDestinationAddress" ] |
|
OPX_MYADDRESS, // result: [ "MSourceAddress", "MDestinationAddress", "MONANA", 1000, "memo", "MDestinationAddress", "MDestinationAddress" ] |
|
OP_EQUALVERIFY, // Fail if the destination address is not me. |
|
OP_DROP, // result: [ "MSourceAddress", "MDestinationAddress", "MONANA", 1000 ] |
|
|
|
// Asset check |
|
OP_SWAP, // result: [ "MSourceAddress", "MDestinationAddress", 1000, "MONANA" ] |
|
"MONANA", // result: [ "MSourceAddress", "MDestinationAddress", 1000, "MONANA", "MONANA" ] |
|
OP_EQUALVERIFY, // result: [ "MSourceAddress", "MDestinationAddress", 1000 ] or fail |
|
|
|
// Return "XMP" |
|
"XMP", // result: [ "MSourceAddress", "MDestinationAddress", 1000, "XMP" ] |
|
OP_SWAP, // result: [ "MSourceAddress", "MDestinationAddress", "XMP", 1000 ] |
|
|
|
// Decrease. Take interest. (the logic is an example. Should be redesigned.) |
|
OPX_CURRENTBLOCK, // result: [ "MSourceAddress", "MDestinationAddress", "XMP", 1000, 100 ] |
|
OPX_BEGINBLOCK, // result: [ "MSourceAddress", "MDestinationAddress", "XMP", 1000, 100, 10 ] |
|
OP_NEGATE, // result: [ "MSourceAddress", "MDestinationAddress", "XMP", 1000, 100, -10 ] |
|
OP_ADD, // result: [ "MSourceAddress", "MDestinationAddress", "XMP", 1000, 90 ] |
|
OP_NEGATE, // result: [ "MSourceAddress", "MDestinationAddress", "XMP", 1000, -90 ] |
|
OP_ADD, // result: [ "MSourceAddress", "MDestinationAddress", "XMP", 990 ] |
|
|
|
// Balance check. |
|
OP_DUP, // result: [ "MSourceAddress", "MDestinationAddress", "XMP", 990, 990 ] |
|
0, // result: [ "MSourceAddress", "MDestinationAddress", "XMP", 990, 990, 0 ] |
|
OP_GRATERTHAN, // result: [ "MSourceAddress", "MDestinationAddress", "XMP", 990, OP_1 ] |
|
OP_EQUALVERIFY, // result: [ "MSourceAddress", "MDestinationAddress", "XMP", 990, OP_1 ] or fail |
|
|
|
// Build message |
|
"MONANA" // result: [ "MSourceAddress", "MDestinationAddress", 1000, "XMP" ] |
|
OP_SWAP, // result: [ "MSourceAddress", "MDestinationAddress", "XMP", 1000 ] |
|
OP_2SWAP, // result: [ "XMP", 1000, "MSourceAddress", "MDestinationAddress" ] |
|
OP_SWAP, // result: [ "XMP", 1000, "MDestinationAddress", "MSourceAddress" ] |
|
OP_2SWAP, // result: [ "MDestinationAddress", "MSourceAddress", "XMP", 1000 ] |
|
OP_1, // result: [ "MDestinationAddress", "MSourceAddress", "XMP", 1000, OP_1 ] // OP_1 means "send" |
|
OPX_BUILDMESSAGE, // result [ ] |
|
|
|
OP_1 // result: [ OP_1 ] // means success. |
|
], |
|
message: {} // will be built on the script. |
|
} |