{
"inputs": [
{
"address": "|DEPOSITOR|",
"amount": 1
}
],
"outputs": [
{
"address": "|DEPOSITOR|",
"amount": 1
},
{
"address": "|PLAYERX|",
"amount": 1
},
{
"address": "|PLAYERO|",
"amount": 1
}
],
"blockheight": 60221409,
"salt": "|RANDOM|",
"contractid": "|ContractID|",
"schema": "octoe-v1",
"state": [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ],
"actions": {
"ENDO": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1 ],
"ENDX": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 1 ],
"EXEC": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, -1, -1 ],
"O00": [ -1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 1, 0, 0, 0 ],
"O01": [ 0, -1, 0, 0, 0, 0, 0, 0, 0, -1, 1, 0, 0, 0 ],
"O02": [ 0, 0, -1, 0, 0, 0, 0, 0, 0, -1, 1, 0, 0, 0 ],
"O10": [ 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 1, 0, 0, 0 ],
"O11": [ 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 1, 0, 0, 0 ],
"O12": [ 0, 0, 0, 0, 0, -1, 0, 0, 0, -1, 1, 0, 0, 0 ],
"O20": [ 0, 0, 0, 0, 0, 0, -1, 0, 0, -1, 1, 0, 0, 0 ],
"O21": [ 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 1, 0, 0, 0 ],
"O22": [ 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 1, 0, 0, 0 ],
"WINO": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 1, 0, 0 ],
"WINX": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0 ],
"X00": [ -1, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0 ],
"X01": [ 0, -1, 0, 0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0 ],
"X02": [ 0, 0, -1, 0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0 ],
"X10": [ 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0 ],
"X11": [ 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, -1, 0, 0, 0 ],
"X12": [ 0, 0, 0, 0, 0, -1, 0, 0, 0, 1, -1, 0, 0, 0 ],
"X20": [ 0, 0, 0, 0, 0, 0, -1, 0, 0, 1, -1, 0, 0, 0 ],
"X21": [ 0, 0, 0, 0, 0, 0, 0, -1, 0, 1, -1, 0, 0, 0 ],
"X22": [ 0, 0, 0, 0, 0, 0, 0, 0, -1, 1, -1, 0, 0, 0 ]
},
"guards": [
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0 ],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0 ],
],
"conditions": [
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1 ],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0 ],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0 ]
]
}
First event triggers the EXEC 'BEGIN' transaction and includes a json-serialized payload containging contract declaration
{
"timestamp": 1541078199752125017,
"schema": "octoe-v1",
"action": "EXEC",
"oid": "|ContractID|",
"value": 1,
"input": [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ],
"output": [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0 ],
"payload": "deadBeefewogICAgImlucHV0cyI6IFsKICAgICAgICB7CiAgICAgICAgICAgICJhZGRyZXNzIj="
}
{
"timestamp": 1541078199752724107,
"schema": "octoe-v1",
"action": "X11",
"oid": "|ContractID|",
"value": 1,
"input": [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0 ],
"output": [ 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 ],
"payload": "e30="
}
{
"timestamp": 1541078199752826526,
"schema": "octoe-v1",
"action": "O01",
"oid": "|ContractID|",
"value": 1,
"input": [ 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 ],
"output": [ 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0 ],
"payload": "e30="
}
{
"timestamp": 1541078199752920020,
"schema": "octoe-v1",
"action": "X00",
"oid": "|ContractID|",
"value": 1,
"input": [ 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0 ],
"output": [ 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 ],
"payload": "e30="
}
{
"timestamp": 1541078199753010166,
"schema": "octoe-v1",
"action": "O02",
"oid": "|ContractID|",
"value": 1,
"input": [ 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 ],
"output": [ 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0 ],
"payload": "e30="
}
{
"timestamp": 1541078199753095273,
"schema": "octoe-v1",
"action": "X22",
"oid": "|ContractID|",
"value": 1,
"input": [ 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0 ],
"output": [ 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0 ],
"payload": "e30="
}
{
"timestamp": 1541078199753199866,
"schema": "octoe-v1",
"action": "WINX",
"oid": "|ContractID|",
"value": 1,
"input": [ 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0 ],
"output": [ 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0 ],
"payload": "e30="
}
{
"inputs": [ { "address": "|DEPOSITOR|", "amount": 1 } ],
"outputs": [
{
"address": "|DEPOSITOR|",
"amount": 1
},
{
"address": "|PUBKEY1|",
"amount": 1
},
{
"address": "|PUBKEY2|",
"amount": 1
}
],
"blockheight": 60221409,
"salt": "|RANDOM|",
"contractid": "|ContractID|",
"schema": "option-v1",
"state": [ 1, 1, 1, 1, 1 ],
"actions": {
"EXEC": [ 0, -1, -1, 0, -1 ],
"FAIL": [ -1, 0, 0, -1, 1 ],
"HALT": [ 0, 0, 0, -1, 0 ],
"OPT_0": [ -1, 1, 0, 0, 0 ],
"OPT_1": [ -1, 0, 1, 0, 0 ]
},
"guards": [
[ 0, 0, 0, -1, 0 ],
[ 0, 0, 0, -1, 0 ],
[ 0, 0, 0, -1, 0 ]
],
"conditions": [
[ 0, 0, 0, 0, -1 ],
[ 0, -1, 0, 0, 0 ],
[ 0, 0, -1, 0, 0 ]
]
}
{
"timestamp": 1541078199753397543,
"schema": "option-v1",
"action": "EXEC",
"oid": "|ContractID|",
"value": 1,
"input": [ 1, 1, 1, 1, 1 ],
"output": [ 1, 0, 0, 1, 0 ],
"payload": "deadBeefewogICAgImlucHV0cyI6IFsKICAgICAgICB7CiAgICAgICAgICAgICJhZGRyZXNzIj="
}
{
"timestamp": 1541078199753569309,
"schema": "option-v1",
"action": "OPT_0",
"oid": "|ContractID|",
"value": 1,
"input": [ 1, 0, 0, 1, 0 ],
"output": [ 0, 1, 0, 1, 0 ],
"payload": "e30="
}
This action is called HALT (and also happens to halt the contract)
{
"timestamp": 1541078199753664258,
"schema": "option-v1",
"action": "HALT",
"oid": "|ContractID|",
"value": 1,
"input": [ 0, 1, 0, 1, 0 ],
"output": [ 0, 1, 0, 0, 0 ],
"payload": "e30="
}
Intro
Here's some sample data showing 2 petri-net smart contracts - one is a game of tic-tac-toe and the other is a simple 'option' contract where an offer is made to 2 addresses and can only be redeemed by 1 or sent back to depositor
Redeem With State
the general idea is that a transaction is completed w/ normal key /RCD validation Plus an additional restriction that the 'conditions' specified in the contract are met
State Conditions
(like an Access Control List) guards & conditions prevent input actions & release of tokens respectively
unless the given state is deemed valid
'Valid'
in this model - valid means state vector can be added to condition w/o resulting in any values < 1
Halting State
The contract is complete when it is 'halted' - when there are no valid moves left
contract expires if it does not halt before the specified blockheight
Related
bisimulation - is a concept I've been trying to integrate - https://en.wikipedia.org/wiki/Bisimulation - I think it's a great way to think about what is going on with this model
The general approach for aggregating events to calculate state is widely known as https://martinfowler.com/eaaDev/EventSourcing.html