forked from FACINGS/pyntelope
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend_message.py
33 lines (23 loc) · 889 Bytes
/
send_message.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
"""Send a message."""
import pyntelope
data = [
# Not specifying an account with the "to" field will send the message to the same account sending it in the "from" field
pyntelope.Data(name="from", value=pyntelope.types.Name("me.wam")),
pyntelope.Data(
name="message",
value=pyntelope.types.String("hello from pyntelope"), # String specified for message type, type must be specificed
),
]
auth = pyntelope.Authorization(actor="me.wam", permission="active")
action = pyntelope.Action(
account="me.wam",
name="sendmsg",
data=data,
authorization=[auth],
)
raw_transaction = pyntelope.Transaction(actions=[action])
net = pyntelope.Local()
linked_transaction = raw_transaction.link(net=net)
key = "a_very_secret_key"
signed_transaction = linked_transaction.sign(key=key)
resp = signed_transaction.send()