-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInteraction.py
More file actions
31 lines (22 loc) · 897 Bytes
/
Interaction.py
File metadata and controls
31 lines (22 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from Wallet import Wallet
from BlockchainUtils import BlockchainUtils
import requests
def postTransaction(sender, receiver, amount, type):
transaction = sender.createTransaction(
receiver.publicKeyString(), amount, type)
url = "http://localhost:5000/transaction"
package = {'transaction': BlockchainUtils.encode(transaction)}
request = requests.post(url, json=package)
if __name__ == '__main__':
bob = Wallet()
alice = Wallet()
alice.fromKey('keys/stakerPrivateKey.pem')
exchange = Wallet()
# forger: genesis
postTransaction(exchange, alice, 100, 'EXCHANGE')
postTransaction(exchange, bob, 100, 'EXCHANGE')
postTransaction(exchange, bob, 10, 'EXCHANGE')
# forger: probably alice
postTransaction(alice, alice, 25, 'STAKE')
postTransaction(alice, bob, 1, 'TRANSFER')
postTransaction(alice, bob, 1, 'TRANSFER')