output = sys.argv[4] input = sys.argv[5] all_users = [] with open(input, 'r') as f: for line in f: line = line.rstrip('\n') segments = line.split(',') u = { 'private_key': segments[0], 'address': segments[1], 'kitty': segments[2], } all_users.append(u) cli = Cli(HTTPProvider(frontend)) compiled_sol = compile_contracts('./contract') kitty_core = compiled_sol['./contract/KittyCore.sol:KittyCore'] kitty_core_contract = cli.eth.contract( abi=kitty_core['abi'], address=kitty_core_address, ) num_per_batch = 1000 lines = [] def make_one_batch(i): users = all_users[i * 2000:(i + 1) * 2000] for i in range(num_per_batch):
import sys sys.path.append('../../..') from ammolite import (Cli, HTTPProvider, Account) import time cli = Cli(HTTPProvider('http://192.168.1.111:8080')) acc_from = Account('316b4cb5409a7c8998c04ad81ffb5f771c70ae7305cbd976845c27320aa2fb36') to_address1 = 'd024a83F83394B90AA2db581250Bc00B0B0f414a' to_address2 = 'd7cB260c7658589fe68789F2d678e1e85F7e4831' origin_balance_from = cli.getBalance(acc_from.address()) origin_balance_to1 = cli.getBalance(to_address1) origin_balance_to2 = cli.getBalance(to_address2) print('Before transfer:') print(f'\tBalance of {acc_from.address()}: {origin_balance_from}') print(f'\tBalance of {to_address1}: {origin_balance_to1}') print(f'\tBalance of {to_address2}: {origin_balance_to2}') raw_tx1, tx_hash1 = acc_from.sign({ 'nonce': 1, 'value': origin_balance_from - 21000, 'gas': 21000, 'gasPrice': 1, 'data': b'', 'to': bytearray.fromhex(to_address1) }) raw_tx2, tx_hash2 = acc_from.sign({ 'nonce': 2, 'value': origin_balance_from - 21000, 'gas': 21000,
contract Example { uint256 value = 0; constructor(uint256 n) public { value = n; } function func1(uint256 n) public { value = n; } } ''' compiled_sol = compile_source(source) _, contract_interface = compiled_sol.popitem() cli = Cli(HTTPProvider("http://localhost:8080")) example_contract = cli.eth.contract(abi=contract_interface['abi'], bytecode=contract_interface['bin']) tx = example_contract.constructor(1).buildTransaction({ 'nonce': 1, 'gas': 100000, 'gasPrice': 100, }) print(tx) account = Account( "cfac4f5fa828072ba8313b0686f02f576fa0fc8caba947569429e88968577865") raw_tx, tx_hash = account.sign(tx) # print("raw_tx = {}, tx_hash = {}".format(raw_tx, tx_hash))
import sys import time sys.path.append('../') from ammolite import (Cli, HTTPProvider, Account) frontend = sys.argv[1] #cli = Cli(HTTPProvider("http://192.168.1.111:8080")) cli = Cli(HTTPProvider("http://" + frontend)) willQuery = True blockHeight = 0 queryCount = 0 while willQuery: block = cli.getBlock(-1) print(block['height']) if blockHeight > 0 and block['height'] > blockHeight: willQuery = False print('Cluster is runing.....') else: blockHeight = block['height'] queryCount = queryCount + 1 if queryCount > 5: break time.sleep(5) if willQuery: print('Cluster status error, please contact system administrator.....')