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,
kitty_core = compiled_sol['./contract/KittyCore.sol:KittyCore'] kitty_core_contract = cli.eth.contract( abi=kitty_core['abi'], address='b1e0e9e68297aae01347f6ce0ff21d5f72d3fa0f', ) coo_private_key = '2289ae919f03075448d567c9c4a22846ce3711731c895f1bea572cef25bb346f' user_private_key = 'd9815a0fa4f31172530f17a6ae64bf5f00a3a651f3d6476146d2c62ae5527dc4' coo = Account(coo_private_key) user1 = Account(user_private_key) user2_address = '230DCCC4660dcBeCb8A6AEA1C713eE7A04B35cAD' raw_tx, tx_hash = coo.sign( kitty_core_contract.functions.createPromoKitty( 0, user1.address()).buildTransaction({ 'gas': 1000000, 'gasPrice': 1, })) cli.sendTransactions({tx_hash: raw_tx}) receipts = [] while True: receipts = cli.getTransactionReceipts([tx_hash]) if receipts is None or len(receipts) != 1: time.sleep(1) continue break events = kitty_core_contract.processReceipt(receipts[0]) new_kitty = events['Birth']['kittyId'] print(
raw_tx2, tx_hash2 = ceo.sign( kitty_core_contract.functions.setSiringAuctionAddress( siring_auction_address).buildTransaction({ 'nonce': 6, 'gas': 100000000, 'gasPrice': 1, })) raw_tx3, tx_hash3 = ceo.sign( kitty_core_contract.functions.setGeneScienceAddress( gene_science_address).buildTransaction({ 'nonce': 7, 'gas': 100000000, 'gasPrice': 1, })) raw_tx4, tx_hash4 = ceo.sign( kitty_core_contract.functions.setCOO(coo.address()).buildTransaction({ 'nonce': 8, 'gas': 100000000, 'gasPrice': 1, })) raw_tx5, tx_hash5 = ceo.sign( kitty_core_contract.functions.setCFO(cfo.address()).buildTransaction({ 'nonce': 9, 'gas': 100000000, 'gasPrice': 1,
raw_tx1, tx_hash1 = ceo.sign(kitty_core_contract.functions.setSaleAuctionAddress(sale_auction_address).buildTransaction({ 'nonce': 5, 'gas': 100000000, 'gasPrice': 1, })) raw_tx2, tx_hash2 = ceo.sign(kitty_core_contract.functions.setSiringAuctionAddress(siring_auction_address).buildTransaction({ 'nonce': 6, 'gas': 100000000, 'gasPrice': 1, })) raw_tx3, tx_hash3 = ceo.sign(kitty_core_contract.functions.setGeneScienceAddress(gene_science_address).buildTransaction({ 'nonce': 7, 'gas': 100000000, 'gasPrice': 1, })) raw_tx4, tx_hash4 = ceo.sign(kitty_core_contract.functions.setCOO(coo.address()).buildTransaction({ 'nonce': 8, 'gas': 100000000, 'gasPrice': 1, })) raw_tx5, tx_hash5 = ceo.sign(kitty_core_contract.functions.setCFO(cfo.address()).buildTransaction({ 'nonce': 9, 'gas': 100000000, 'gasPrice': 1, })) cli.sendTransactions({tx_hash1: raw_tx1, tx_hash2: raw_tx2, tx_hash3: raw_tx3, tx_hash4: raw_tx4, tx_hash5: raw_tx5}) check_receipts(wait_for_receipts(cli, [tx_hash1, tx_hash2, tx_hash3, tx_hash4, tx_hash5])) console.log("Setup runtime parameters of KittyCore complete") # 4. Start service.