VVET_FILE = sys.argv[3] # Prepare wallet and network w = Wallet.fromPrivateKey(bytes.fromhex(PRIVATE_KEY)) c = Connect(NETWORK) vvet_contract = Contract.fromFile(VVET_FILE) # Detect wallet balance account = c.get_account(w.getAddress()) print('Wallet:') print('VET:', int(account['balance'], 16) / (10**18)) print('VTHO:', int(account['energy'], 16) / (10**18)) print('Is human:', not utils.is_contract(account)) # Deploy response = c.deploy(w, vvet_contract, None, None) tx_id = response['id'] print('deploy_vvet_tx:', tx_id) # Wait for Receipt receipt = c.wait_for_tx_receipt(tx_id, 30) if not receipt: raise Exception(f"receipt not found! by tx id: {tx_id}") # Print deployed address if utils.is_reverted(receipt): raise Exception(f"{tx_id} is reverted!") deployed_addresses = utils.read_created_contracts(receipt) for each in deployed_addresses: print('contract_vvet_created:', each)
COMTRACT_FILE = sys.argv[3] # Prepare wallet and network w = Wallet.fromPrivateKey(bytes.fromhex(PRIVATE_KEY)) c = Connect(NETWORK) smart_contract = Contract.fromFile(COMTRACT_FILE) # Detect wallet balance account = c.get_account(w.getAddress()) print('Wallet:') print('VET:', int(account['balance'], 16) / (10 ** 18)) print('VTHO:', int(account['energy'], 16) / (10 ** 18)) print('Is human:', not utils.is_contract(account)) # Deploy response = c.deploy(w, smart_contract, None, None) tx_id = response['id'] print('deploy_tx:', tx_id) # Wait for Receipt receipt = c.wait_for_tx_receipt(tx_id, 30) if not receipt: raise Exception(f"receipt not found! by tx id: {tx_id}") # Print deployed address if utils.is_reverted(receipt): raise Exception(f"{tx_id} is reverted!") deployed_addresses = utils.read_created_contracts(receipt) for each in deployed_addresses: print('contract_created:', each)
# Detect if VVET contract is ready a = c.get_account(vvet_contract_address) if not utils.is_contract(a): raise Exception(f"{vvet_contract_address} is not a smart contract") # Detect wallet balance account = c.get_account(w.getAddress()) print('Wallet balance:') print('VET:', int(account['balance'], 16) / (10**18)) print('VTHO:', int(account['energy'], 16) / (10**18)) print('Is human:', not utils.is_contract(account)) # Deploy Factory fee_to_setter = w.getAddress() # fee to setter is me. response = c.deploy(w, factory_contract, ['address', 'address'], [fee_to_setter, vvet_contract_address]) tx_id = response['id'] print('deploy_factory_tx:', tx_id) # Wait for Receipt receipt = c.wait_for_tx_receipt(tx_id, 30) if not receipt: raise Exception(f"receipt not found! by tx id: {tx_id}") # Print deployed address if utils.is_reverted(receipt): print(c.replay_tx(tx_id)) raise Exception(f"{tx_id} is reverted!") deployed_factory_addresses = utils.read_created_contracts(receipt) factory_address = deployed_factory_addresses[0]
c = Connect(NETWORK) smart_contract = Contract.fromFile(COMTRACT_FILE) # Detect wallet balance account = c.get_account(w.getAddress()) print('Wallet:') print('VET:', int(account['balance'], 16) / (10 ** 18)) print('VTHO:', int(account['energy'], 16) / (10 ** 18)) print('Is human:', not utils.is_contract(account)) # Deploy ## get block block = c.get_block() best_block_number = int(block['number']) stop_block_number = best_block_number + int(HOW_MANY_BLOCKS_LATER) response = c.deploy(w, smart_contract, ['uint', 'bool', 'uint'], [stop_block_number, True, 1 * (10**18)]) tx_id = response['id'] print('deploy_tx:', tx_id) # Wait for Receipt receipt = c.wait_for_tx_receipt(tx_id, 30) if not receipt: raise Exception(f"receipt not found! by tx id: {tx_id}") # Print deployed address if utils.is_reverted(receipt): raise Exception(f"{tx_id} is reverted!") deployed_addresses = utils.read_created_contracts(receipt) for each in deployed_addresses: print('contract_created:', each)