Last active
June 15, 2020 13:51
-
-
Save vladbatushkov/7dc116d44eb2bcb2bdea401a980b12bb to your computer and use it in GitHub Desktop.
blockchain generation script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MATCH (n) DETACH DELETE n; | |
| CREATE (b:Block {hash: 'block1'}); | |
| // Coinbase 1 | |
| MATCH (b:Block {hash: 'block1'}) | |
| CREATE | |
| (i:Input {coinbase: 'coinbase1'}), | |
| (tx:Transaction {id: 'tx1-1'}), | |
| (o:Output {n: 0, value: 11}), | |
| (a:Address {address: 'addr1-1'}) | |
| CREATE | |
| (tx)-[:TX]->(b), | |
| (i)-[:IN]->(tx), | |
| (tx)-[:OUT]->(o), | |
| (a)-[:LOCKED]->(o); | |
| // Tx 1-1 | |
| MATCH (b:Block {hash: 'block1'}) | |
| CREATE | |
| (i1:Input {tx_id: 'tx1-2', vout: 0}), | |
| (i2:Input {tx_id: 'tx3-4', vout: 0}), | |
| (tx:Transaction {id: 'tx1-2'}), | |
| (o1:Output {n: 0, value: 11}), | |
| (o2:Output {n: 1, value: 0.11}), | |
| (a1:Address {address: 'addr1-2'}), | |
| (a2:Address {address: 'addr1-3'}) | |
| CREATE | |
| (tx)-[:TX]->(b), | |
| (i1)-[:IN]->(tx), | |
| (i2)-[:IN]->(tx), | |
| (tx)-[:OUT]->(o1), | |
| (tx)-[:OUT]->(o2), | |
| (a1)-[:OUT]->(o1), | |
| (a2)-[:OUT]->(o2); | |
| CREATE (b:Block {hash: 'block2'}); | |
| // Coinbase 2 | |
| MATCH (b:Block {hash: 'block2'}) | |
| CREATE | |
| (i:Input {coinbase: 'coinbase2'}), | |
| (tx:Transaction {id: 'tx2-1'}), | |
| (o:Output {n: 0, value: 22}), | |
| (a:Address {address: 'addr2-1'}) | |
| CREATE | |
| (tx)-[:TX]->(b), | |
| (i)-[:IN]->(tx), | |
| (tx)-[:OUT]->(o), | |
| (a)-[:LOCKED]->(o); | |
| // Tx 2-1 | |
| MATCH (b:Block {hash: 'block2'}) | |
| CREATE | |
| (i:Input {tx_id: 'tx3-2', vout: 0}), | |
| (tx:Transaction {id: 'tx2-2'}), | |
| (o1:Output {n: 0, value: 22}), | |
| (o2:Output {n: 1, value: 0.22}), | |
| (a1:Address {address: 'addr2-2'}), | |
| (a2:Address {address: 'addr2-3'}) | |
| CREATE | |
| (tx)-[:TX]->(b), | |
| (i)-[:IN]->(tx), | |
| (tx)-[:OUT]->(o1), | |
| (tx)-[:OUT]->(o2), | |
| (a1)-[:OUT]->(o1), | |
| (a2)-[:OUT]->(o2); | |
| // Merge | |
| MATCH (tx:Transaction {id: 'tx2-2'})-[:OUT]->(o:Output {n: 0}), (i:Input {tx_id: 'tx1-2'}) | |
| MERGE (o)-[:UNLOCK]->(i); | |
| CREATE (b:Block {hash: 'block3'}); | |
| // Coinbase 3 | |
| MATCH (b:Block {hash: 'block3'}) | |
| CREATE | |
| (i:Input {coinbase: 'coinbase3'}), | |
| (tx:Transaction {id: 'tx3-1'}), | |
| (o:Output {n: 0, value: 33}), | |
| (a:Address {address: 'addr3-1'}) | |
| CREATE | |
| (tx)-[:TX]->(b), | |
| (i)-[:IN]->(tx), | |
| (tx)-[:OUT {}]->(o), | |
| (a)-[:LOCKED]->(o); | |
| // Tx 3-1 | |
| MATCH (b:Block {hash: 'block3'}) | |
| CREATE | |
| (i:Input {tx_id: 'tx4-2', vout: 0}), | |
| (tx:Transaction {id: 'tx3-2'}), | |
| (o1:Output {n: 0, value: 33}), | |
| (o2:Output {n: 1, value: 0.33}), | |
| (a1:Address {address: 'addr3-2'}), | |
| (a2:Address {address: 'addr3-3'}) | |
| CREATE | |
| (tx)-[:TX]->(b), | |
| (i)-[:IN]->(tx), | |
| (tx)-[:OUT]->(o1), | |
| (tx)-[:OUT]->(o2), | |
| (a1)-[:OUT]->(o1), | |
| (a2)-[:OUT]->(o2); | |
| // Tx 3-2 | |
| MATCH (b:Block {hash: 'block3'}) | |
| CREATE | |
| (i:Input {tx_id: 'tx4-2', vout: 0}), | |
| (tx:Transaction {id: 'tx3-3'}), | |
| (o1:Output {n: 0, value: 33}), | |
| (o2:Output {n: 1, value: 0.33}), | |
| (a1:Address {address: 'addr3-4'}), | |
| (a2:Address {address: 'addr3-5'}) | |
| CREATE | |
| (tx)-[:TX]->(b), | |
| (i)-[:IN]->(tx), | |
| (tx)-[:OUT]->(o1), | |
| (tx)-[:OUT]->(o2), | |
| (a1)-[:OUT]->(o1), | |
| (a2)-[:OUT]->(o2); | |
| MATCH (b:Block {hash: 'block3'}) | |
| CREATE | |
| (i1:Input {tx_id: 'tx4-2', vout: 0}), | |
| (i2:Input {tx_id: 'tx4-4', vout: 0}), | |
| (tx:Transaction {id: 'tx3-4'}), | |
| (o1:Output {n: 0, value: 333}), | |
| (o2:Output {n: 1, value: 0.333}), | |
| (a1:Address {address: 'addr3-6'}), | |
| (a2:Address {address: 'addr3-7'}) | |
| CREATE | |
| (tx)-[:TX]->(b), | |
| (i1)-[:IN]->(tx), | |
| (i2)-[:IN]->(tx), | |
| (tx)-[:OUT]->(o1), | |
| (tx)-[:OUT]->(o2), | |
| (a1)-[:OUT]->(o1), | |
| (a2)-[:OUT]->(o2); | |
| // Merge | |
| MATCH (tx:Transaction {id: 'tx3-2'})-[:OUT]->(o:Output {n: 0}), (i:Input {tx_id: 'tx3-2'}) | |
| MERGE (o)-[:UNLOCK]->(i); | |
| MATCH (tx:Transaction {id: 'tx3-4'})-[:OUT]->(o:Output {n: 0}), (i:Input {tx_id: 'tx1-2'}) | |
| MERGE (o)-[:UNLOCK]->(i); | |
| // Block 4 | |
| CREATE (b:Block {hash: 'block4'}); | |
| // Coinbase 3 | |
| MATCH (b:Block {hash: 'block4'}) | |
| CREATE | |
| (i:Input {coinbase: 'coinbase4'}), | |
| (tx:Transaction {id: 'tx4-1'}), | |
| (o:Output {n: 0, value: 44}), | |
| (a:Address {address: 'addr4-1'}) | |
| CREATE | |
| (tx)-[:TX]->(b), | |
| (i)-[:IN]->(tx), | |
| (tx)-[:OUT {}]->(o), | |
| (a)-[:LOCKED]->(o); | |
| // Tx4-1 | |
| MATCH (b:Block {hash: 'block4'}) | |
| CREATE | |
| (i:Inpu {tx_id: 'tx5-2', vout: 0}), | |
| (tx:Transaction {id: 'tx4-2'}), | |
| (o1:Output {n: 0, value: 44}), | |
| (o2:Output {n: 1, value: 0.44}), | |
| (a1:Address {address: 'addr4-2'}), | |
| (a2:Address {address: 'addr4-3'}) | |
| CREATE | |
| (tx)-[:TX]->(b), | |
| (i)-[:IN]->(tx), | |
| (tx)-[:OUT]->(o1), | |
| (tx)-[:OUT]->(o2), | |
| (a1)-[:OUT]->(o1), | |
| (a2)-[:OUT]->(o2); | |
| MATCH (:Transaction {id: 'tx4-2'})-[:OUT]->(o:Output {n: 0}), (i:Input {tx_id: 'tx4-2'}) | |
| MERGE (o)-[:UNLOCK]->(i); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment