Permalink
Cannot retrieve contributors at this time
import time | |
from web3.auto import w3 | |
from solc import compile_source | |
from web3 import Web3 | |
from web3.contract import ConciseContract | |
# Path of the source code of the SMT contract | |
sol_path = "/media/sf_Shared_Folder/stm-contrace_original.sol" | |
interface_keystr = '<stdin>:SMT' | |
account = w3.eth.coinbase | |
pin = " " # password to unlock the account | |
contract_file = open(sol_path) | |
contract_soucecode = contract_file.read() | |
compiled_sol = compile_source(contract_soucecode) | |
contract_interface = compiled_sol[interface_keystr] | |
contract = w3.eth.contract(abi=contract_interface['abi'], bytecode=contract_interface['bin']) | |
w3.personal.unlockAccount(account, pin) | |
gas = contract.constructor().estimateGas() | |
tx_hash = contract.deploy(transaction={'from': account, 'gas': gas}) | |
while True: | |
tx_receipt = w3.eth.getTransactionReceipt(tx_hash) | |
if tx_receipt != None: | |
break | |
time.sleep(1) | |
contract_address = tx_receipt['contractAddress'] | |
print('Contract Address: ' + contract_address) | |
contract = w3.eth.contract(address=contract_address, abi=contract_interface['abi']) | |
func = contract.functions.enableTransfer(True) | |
gas = func.estimateGas() | |
tid = func.transact(transaction={'from': account, 'gas': gas}) | |
while True: | |
tx_receipt = w3.eth.getTransactionReceipt(tid) | |
if tx_receipt != None: | |
print("RECEIPT: " + str(tx_receipt)) | |
break | |
time.sleep(1) |