-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdeploy_smart_contract.py
66 lines (56 loc) · 1.63 KB
/
deploy_smart_contract.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"""Deploy a smart contract."""
import pyntelope
setcode_data = [
# data to set wasm file to account me.wam
pyntelope.Data(
name="account",
value=pyntelope.types.Name("me.wam"),
),
pyntelope.Data(
name="vmtype",
value=pyntelope.types.Uint8(0), # almost always set to 0, has to be set
),
pyntelope.Data(
name="vmversion",
value=pyntelope.types.Uint8(0), # almost always set to 0, has to be set
),
pyntelope.Data(
name="code", # select "code" field to set a wasm file
value=pyntelope.types.Wasm.from_file(
"test_contract/test_contract.zip"
), # path from current directory to wasm file
),
]
setabi_data = [
pyntelope.Data(
name="account",
value=pyntelope.types.Name("me.wam"),
),
pyntelope.Data(
name="abi", # select "abi" field to set a abi file
value=pyntelope.types.Abi.from_file(
"test_contract/test_contract.abi"
), # path from current directory to abi file
),
]
auth = pyntelope.Authorization(actor="me.wam", permission="active")
setcode_action = pyntelope.Action(
account="eosio",
name="setcode",
data=setcode_data,
authorization=[auth],
)
setabi_action = pyntelope.Action(
account="eosio",
name="setabi",
data=setabi_data,
authorization=[auth],
)
raw_transaction = pyntelope.Transaction(
actions=[setabi_action, setcode_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()