1
- #Import library and modulesfrom hedera import PrivateKey
2
- from hedera import FileId , FileContentsQuery
1
+ #Import library and modules
3
2
import os
4
3
from hedera import (
5
4
Hbar ,
6
5
FileCreateTransaction ,
7
6
ContractCreateTransaction ,
8
- ContractCallQuery ,
9
- ContractDeleteTransaction ,
7
+ FileContentsQuery ,
10
8
AccountId ,
11
9
PrivateKey ,
12
10
Client
13
11
)
14
12
15
- #create function
13
+ #create function to deploy contract
16
14
def deployContract ():
15
+
17
16
#Get operator AccountID and PvtKey
18
- OPERATOR_ID = AccountId .fromString ('0.0.13752044 ' )
19
- OPERATOR_KEY = PrivateKey .fromString ('302e020100300506032b657004220420aa2f73270c906f5a4ffafd8c42261b7b7fcfdb83d15bdcbacbad3bd140039302 ' )
17
+ OPERATOR_ID = AccountId .fromString ('Get yours on Hedera Portal ' )
18
+ OPERATOR_KEY = PrivateKey .fromString ('Get yours on Hedera Portal ' )
20
19
21
20
#Create client class using Operator credentials. In this case we also setup max txn fee and max query payment since the transaction we are going to execute could have an higher gas limit and could be more expensive than other ones.
22
21
client = Client .forTestnet ()
@@ -27,7 +26,6 @@ def deployContract():
27
26
#bytecode of the Smart contract compiled
28
27
byteCode = '608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506101cb806100606000396000f3fe608060405260043610610046576000357c01000000000000000000000000000000000000000000000000000000009004806341c0e1b51461004b578063cfae321714610062575b600080fd5b34801561005757600080fd5b506100606100f2565b005b34801561006e57600080fd5b50610077610162565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100b757808201518184015260208101905061009c565b50505050905090810190601f1680156100e45780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610160573373ffffffffffffffffffffffffffffffffffffffff16ff5b565b60606040805190810160405280600d81526020017f48656c6c6f2c20776f726c64210000000000000000000000000000000000000081525090509056fea165627a7a72305820ae96fb3af7cde9c0abfe365272441894ab717f816f07f41f07b1cbede54e256e0029' .encode ()
29
28
30
-
31
29
#create Transaction to store on Hedera the file that will contain SC bytecode and execute it
32
30
tnx = FileCreateTransaction ()
33
31
resp = tnx .setKeys (OPERATOR_KEY .getPublicKey ()).setContents (byteCode ).setMaxTransactionFee (Hbar (2 )).execute (client )
@@ -49,6 +47,6 @@ def deployContract():
49
47
receipt = tran .getReceipt (client )
50
48
contractId = receipt .contractId
51
49
52
- contract_tx_id = receipt .transactionId .toString ())
50
+ contract_tx_id = receipt .transactionId .toString ()
53
51
contract_id = contractId .toString ()
54
52
0 commit comments