{
"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="
}
Q: In the tic-tac-toe how do you identity each players?
A: There is a 'role' place that indicates whose turn it is - the Guard conditions relate the key ordering to state TODO: add explicit examples
Q: Any particular reason you encode base64 the payload?
A: mostly because Golang marshalled the json-encoded string that way in my demo code - could change to just be json (though I like the idea that it could be encryped bytes also)
Q: Do you have tool that convert those matrix/vector to graphical representation?
A: I've sortof been going the other way - designing graphical and then converting using: https://www.blahchain.com/PetriNetEditor/ and http://sarahtattersall.github.io/PIPE/
Q: Why do you need to put input and output as part of the entry? As you said, it is Event sourcing so the state should be calculated by the program reading the chain, why is there a need to store the calculated state?
A: you are correct these values can be recomputed (I could be convinced to leave this out)- I added this data to the payload because makes auditing trivial
Q: Why value is always = 1 in the tic tac toe
A: this is a 'multiplier' - each of the transform vectors in the state machine can be executed 'N' times by including a value > 1
this is added to allow contracts where we need to specify an 'amount' - basically the actions can be thought of as 'Unit Vectors' in that case
Q: Why does an explicit WINX event needs to be submitted? Isn't it just the consequence of all previous moves? Which party is supposed to emit this WIN event?
A: WINX isn't really required - the evidence for the winner is in the chain by the time this event is added - I added this mechanism as sort of an illustration whereby the original depositor is the Judge of the game.
Q: How to apply the "conditions"? I mean how do I know if a state satisfy the conditions? Kind of the same question for guards?
A: conditions are applied by adding vectors - if the sum contains any negative values - the condition is False/Invalid (I will release code soon)
Q: I see there are as many guards as there are outputs, is that a coincidence? Or maybe I haven't understood what guards are, could you re explain me please?
A: not a coincidence - guards restrict who is 'allowed' to interact w/ the state machine at a givn state - the order of Outputs corresponds to the 'Role' being asserted by a Guard clause
Q:the "conditions" allow to describe the conditions that need to be met for the token to be released right? But how did you encode to WHO it should be , is it just the ordering of conditions that match ordering of outputs?
A: yes - the ordering of outputs corresponds to the 'Who' has unlocked the funds