-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathvoting.py
52 lines (44 loc) · 1.43 KB
/
voting.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""Vote to a nice blockproducer ;) ."""
import pyntelope
data = [
# Specifices the voter account
pyntelope.Data(
name="voter",
value=pyntelope.types.Name("me.wam"),
),
# Specifices the proxy (can be empty)
pyntelope.Data(
name="proxy",
value=pyntelope.types.Name(""),
),
# Specifics the producers
pyntelope.Data(
name="producers",
# One can vote for mutliple producers, so value is of type array
# An Array is what is called a Composte type. It is formed of multiple
# others pyntelope types.
# Compostes types instantiation are more verbose.
value=pyntelope.types.Array.from_dict(
["eosiodetroit"], type_=pyntelope.types.Name
),
# If you want to instantiate it directly you'd need to provide a tuple
# of names:
# value=pyntelope.types.Array(
# values=(pyntelope.types.Name("eosiodetroit")),
# type_=pyntelope.types.Name,
# ),
),
]
auth = pyntelope.Authorization(actor="me.wam", permission="active")
action = pyntelope.Action(
account="eosio",
name="voteproducer",
data=data,
authorization=[auth],
)
raw_transaction = pyntelope.Transaction(actions=[action])
net = pyntelope.WaxTestnet()
linked_transaction = raw_transaction.link(net=net)
key = "a_very_secret_key"
signed_transaction = linked_transaction.sign(key=key)
resp = signed_transaction.send()