def test_invoke_a_b(self): code_b = "59c56b6a00527ac46a51527ac46a00c308696e766f6b655f619c640b006a51c300c3656e00616a00c309696e766f6b655f61319c640e006a51c300c3650b006c756661006c756656c56b6a00527ac46a00c3026f700461726773527268174e656f2e4170702e526567697374657241707043616c6c616a51527ac46a51c3057465737431006a52527ac46a52c36c756656c56b6a00527ac46a00c3026f700461726773527268174e656f2e4170702e526567697374657241707043616c6c616a51527ac46a51c30474657374037374686a52527ac46a52c3681553797374656d2e52756e74696d652e4e6f7469667961006c75665ec56b6a00527ac46a51527ac46a51c36a00c3946a52527ac46a52c3c56a53527ac4006a54527ac46a00c36a55527ac461616a00c36a51c39f6433006a54c36a55c3936a56527ac46a56c36a53c36a54c37bc46a54c351936a54527ac46a55c36a54c3936a00527ac462c8ff6161616a53c36c7566" code_a = "59c56b6a00527ac46a51527ac46a00c304746573749c6409006a51c3652700616a00c30574657374319c640900650b006c756661006c756653c56b04746573746c756654c56b6a00527ac46a00c3681553797374656d2e52756e74696d652e4e6f7469667961006c75665ec56b6a00527ac46a51527ac46a51c36a00c3946a52527ac46a52c3c56a53527ac4006a54527ac46a00c36a55527ac461616a00c36a51c39f6433006a54c36a55c3936a56527ac46a56c36a53c36a54c37bc46a54c351936a54527ac46a55c36a54c3936a00527ac462c8ff6161616a53c36c7566" abi_b = '{"functions":[{"name":"main","parameters":[{"name":"op","type":""},{"name":"args","type":""}],"returntype":""},{"name":"invoke_a","parameters":[{"name":"addr","type":""}],"returntype":""},{"name":"invoke_a1","parameters":[{"name":"addr","type":""}],"returntype":""},{"name":"makeState","parameters":[{"name":"fromacct","type":""},{"name":"toacct","type":""},{"name":"amount","type":""}],"returntype":""}]}' abi_a = '{"functions":[{"name":"main","parameters":[{"name":"op","type":""},{"name":"args","type":""}],"returntype":""},{"name":"test","parameters":[{"name":"args","type":""}],"returntype":""},{"name":"test1","parameters":[{"name":"","type":""}],"returntype":""}]}' addr_b = Address.address_from_vm_code(code_b) addr_a = Address.address_from_vm_code(code_a) abi_b = json.loads(abi_b) abi_info_b = AbiInfo('0x' + addr_b.to_reverse_hex_str(), 'main', abi_b['functions'], []) abi_a = json.loads(abi_a) abi_info_a = AbiInfo('0x' + addr_a.to_reverse_hex_str(), 'main', abi_a['functions'], []) acc = sdk.get_wallet_manager().get_account( 'ANH5bHrrt111XwNEnuPZj6u95Dd6u7G4D6', '1') func = abi_info_b.get_function('invoke_a') func.set_params_value((addr_a.to_reverse_hex_str(), )) res = sdk.neo_vm().send_transaction(addr_b.to_array(), acc, acc, 200000000, 500, func, False) json_res = sdk.get_rpc().get_smart_contract_event_by_tx_hash(res) while json_res is None: json_res = sdk.get_rpc().get_smart_contract_event_by_tx_hash(res) time.sleep(1) print(json_res) print(res)
def test_checkwitness(self): """ 测试CheckWitness功能以及使用方法 :return: """ code = '59c56b6a00527ac46a51527ac46a00c304746573749c6409006a51c3652700616a00c30574657374319c640900650b006c756661006c756653c56b04746573746c75660113c56b6a00527ac401610162016353c176c96a51527ac4681653797374656d2e52756e74696d652e47657454696d65616a52527ac46a52c3681553797374656d2e52756e74696d652e4e6f74696679616a52c3a76a53527ac46a53c3539753976a53527ac46a53c300876426006a51c36a53c3c3681553797374656d2e52756e74696d652e4e6f7469667961006c7566616a53c351876426006a51c36a53c3c3681553797374656d2e52756e74696d652e4e6f7469667961006c7566616a53c352a26424006a51c352c3681553797374656d2e52756e74696d652e4e6f7469667961006c7566616a53c3681553797374656d2e52756e74696d652e4e6f746966796151681553797374656d2e52756e74696d652e4e6f7469667961006c75665ec56b6a00527ac46a51527ac46a51c36a00c3946a52527ac46a52c3c56a53527ac4006a54527ac46a00c36a55527ac461616a00c36a51c39f6433006a54c36a55c3936a56527ac46a56c36a53c36a54c37bc46a54c351936a54527ac46a55c36a54c3936a00527ac462c8ff6161616a53c36c7566' addr = Address.address_from_vm_code(code) abi = '{"functions":[{"name":"Main","parameters":[{"name":"op","type":""},{"name":"args","type":""}],"returntype":""},{"name":"check","parameters":[{"name":"acc","type":""}],"returntype":""}]}' abi = json.loads(abi, object_hook=lambda d: namedtuple('X', d.keys()) (*d.values())) abi_info = AbiInfo('0x' + addr.to_reverse_hex_str(), 'Main', abi.functions, []) acc = sdk.get_wallet_manager().get_account( 'ANH5bHrrt111XwNEnuPZj6u95Dd6u7G4D6', '1') acc1 = sdk.get_wallet_manager().get_account( 'AazEvfQPcQ2GEFFPLF1ZLwQ7K5jDn81hve', '060708') func = abi_info.get_function('check') func.set_params_value(acc1.get_address().to_byte_array()) res = sdk.neo_vm().send_transaction(addr.to_byte_array(), acc, acc, 200000000, 500, func, False) json_res = sdk.get_rpc().get_smart_contract_event_by_tx_hash(res) while json_res is None: json_res = sdk.get_rpc().get_smart_contract_event_by_tx_hash(res) time.sleep(1) print(json_res) print(res)
def test_input_list(self): code = '59c56b6a00527ac46a51527ac451681553797374656d2e52756e74696d652e4e6f74696679616a00c305746f5f73639c64270052681553797374656d2e52756e74696d652e4e6f74696679616a51c300c3650b006c756661006c756660c56b6a00527ac4682d53797374656d2e457865637574696f6e456e67696e652e476574457865637574696e6753637269707448617368616a51527ac41400000000000000000000000000000000000000016a52527ac46a00c3681b53797374656d2e52756e74696d652e436865636b5769746e6573736163200000681553797374656d2e52756e74696d652e4e6f7469667961006c7566616a00c36a51c35a53c176c96a53527ac4516a52c3087472616e736665726a53c351c176c9537951795572755172755279527954727552727568164f6e746f6c6f67792e4e61746976652e496e766f6b65616a54527ac46a54c3681553797374656d2e52756e74696d652e4e6f74696679616a54c36439006a54c301019c643000107472616e736665722073756363656564681553797374656d2e52756e74696d652e4e6f7469667961516c7566610f7472616e73666572206661696c6564681553797374656d2e52756e74696d652e4e6f7469667961006c7566006c7566' addr = Address.address_from_vm_code(code) abi = '{"functions":[{"name":"Main","parameters":[{"name":"op","type":""},{"name":"args","type":""}],"returntype":""},{"name":"test","parameters":[{"name":"arr","type":""}],"returntype":""}]}' abi = json.loads(abi, object_hook=lambda d: namedtuple('X', d.keys()) (*d.values())) abi_info = AbiInfo('0x' + addr.to_reverse_hex_str(), 'Main', abi.functions, []) acc = sdk.get_wallet_manager().get_account( 'ANH5bHrrt111XwNEnuPZj6u95Dd6u7G4D6', '1') acc1 = sdk.get_wallet_manager().get_account( 'AazEvfQPcQ2GEFFPLF1ZLwQ7K5jDn81hve', '060708') func = abi_info.get_function('test') func.set_params_value([[ acc.get_address().to_byte_array(), acc.get_address().to_byte_array(), 3 ], [ acc.get_address().to_byte_array(), acc.get_address().to_byte_array(), 1 ]]) res = sdk.neo_vm().send_transaction(addr.to_byte_array(), acc1, acc1, 200000000, 500, func, False) json_res = sdk.get_rpc().get_smart_contract_event_by_tx_hash(res) while json_res is None: json_res = sdk.get_rpc().get_smart_contract_event_by_tx_hash(res) time.sleep(1) print(json_res) print(res)
def test_domain(self): """ :return: """ code = '012cc56b6a00527ac46a51527ac4682d53797374656d2e457865637574696f6e456e67696e652e476574457865637574696e6753637269707448617368616a52527ac46a00c30872656769737465729c647a006a51c300c36a53527ac46a51c351c36a54527ac46a53c3681b53797374656d2e52756e74696d652e436865636b5769746e657373616410006a53c36a54c37c65ac0b6c75666114436865636b5769746e657373206661696c656421681553797374656d2e52756e74696d652e4e6f7469667961006c7566616a00c30473656c6c9c6488006a51c300c36a53527ac46a51c351c36a54527ac46a51c352c36a55527ac46a53c3681b53797374656d2e52756e74696d652e436865636b5769746e657373616414006a53c36a54c36a55c3527265bb096c75666114436865636b5769746e657373206661696c656421681553797374656d2e52756e74696d652e4e6f7469667961006c7566616a00c30571756572799c6416006a51c300c36a54527ac46a54c365f2086c7566616a00c3036275799c6488006a51c300c36a53527ac46a51c351c36a54527ac46a51c352c36a55527ac46a53c3681b53797374656d2e52756e74696d652e436865636b5769746e657373616414006a53c36a54c36a55c352726571056c75666114436865636b5769746e657373206661696c656421681553797374656d2e52756e74696d652e4e6f7469667961006c7566616a00c304646f6e659c647a006a51c300c36a53527ac46a51c351c36a54527ac46a53c3681b53797374656d2e52756e74696d652e436865636b5769746e657373616410006a53c36a54c37c65a6006c75666114436865636b5769746e657373206661696c656421681553797374656d2e52756e74696d652e4e6f7469667961006c7566616a00c3087472616e736665729c6428006a51c300c36a56527ac46a51c351c36a57527ac46a56c36a52c36a57c35272651f036c7566611a4e6f74206120737570706f72746564206f7065726174696f6e21681553797374656d2e52756e74696d652e4e6f7469667961516c7566011cc56b6a00527ac46a51527ac4681953797374656d2e53746f726167652e476574436f6e74657874616a52527ac4682d53797374656d2e457865637574696f6e456e67696e652e476574457865637574696e6753637269707448617368616a53527ac41400000000000000000000000000000000000000016a54527ac46a52c36a51c37c681253797374656d2e53746f726167652e476574616a55527ac46a55c36a53c39e642b000b6e6f7420696e2073656c6c681553797374656d2e52756e74696d652e4e6f7469667961006c7566616a52c30f4f726967696e616c5f4f776e65725f6a51c37e7c681253797374656d2e53746f726167652e476574616a56527ac46a56c36a00c39e642900096e6f74206f776e6572681553797374656d2e52756e74696d652e4e6f7469667961006c7566616a52c30650726963655f6a51c37e7c681253797374656d2e53746f726167652e476574616a57527ac46a53c36a00c36a57c353c176c96a58527ac4516a54c3087472616e736665726a58c351c176c9537951795572755172755279527954727552727568164f6e746f6c6f67792e4e61746976652e496e766f6b65616a59527ac46a59c364f7006a59c301019c64ee006a52c30354505f6a51c37e7c681253797374656d2e53746f726167652e476574616a5a527ac46a52c36a51c36a5ac35272681253797374656d2e53746f726167652e507574616a52c30354505f6a51c37e7c681553797374656d2e53746f726167652e44656c657465616a52c30650726963655f6a51c37e7c681553797374656d2e53746f726167652e44656c657465616a52c30f4f726967696e616c5f4f776e65725f6a51c37e7c681553797374656d2e53746f726167652e44656c657465610d646f6e65207375636365656421681553797374656d2e52756e74696d652e4e6f7469667961516c7566610f7472616e73666572206661696c6564681553797374656d2e52756e74696d652e4e6f7469667961006c7566006c75660111c56b6a00527ac46a51527ac46a52527ac41400000000000000000000000000000000000000016a53527ac46a00c3681b53797374656d2e52756e74696d652e436865636b5769746e6573736164e2006a00c36a51c36a52c353c176c96a54527ac4516a53c3087472616e736665726a54c351c176c9537951795572755172755279527954727552727568164f6e746f6c6f67792e4e61746976652e496e766f6b65616a55527ac46a55c3681553797374656d2e52756e74696d652e4e6f74696679616a55c36439006a55c301019c643000107472616e736665722073756363656564681553797374656d2e52756e74696d652e4e6f7469667961516c7566610f7472616e73666572206661696c6564681553797374656d2e52756e74696d652e4e6f7469667961006c75666234006113636865636b5769746e657373206661696c6564681553797374656d2e52756e74696d652e4e6f7469667961006c756661006c75660123c56b6a00527ac46a51527ac46a52527ac4681953797374656d2e53746f726167652e476574436f6e74657874616a53527ac4682d53797374656d2e457865637574696f6e456e67696e652e476574457865637574696e6753637269707448617368616a54527ac46a53c36a51c37c681253797374656d2e53746f726167652e476574616a55527ac46a55c36a54c39e6430001075726c206e6f7420696e2073616c6521681553797374656d2e52756e74696d652e4e6f7469667961006c7566616a53c30354505f6a51c37e7c681253797374656d2e53746f726167652e476574616a56527ac46a53c30650726963655f6a51c37e7c681253797374656d2e53746f726167652e476574616a57527ac46a56c3630b016a52c36a57c3a264c2006a00c36a54c36a52c35272656efd6484006a53c30354505f6a51c37e6a00c35272681253797374656d2e53746f726167652e507574616a52c36a57c3a0642b006a53c30650726963655f6a51c37e6a52c35272681253797374656d2e53746f726167652e50757461610c627579207375636365656421681553797374656d2e52756e74696d652e4e6f7469667961516c7566610f5472616e73666572204661696c6564681553797374656d2e52756e74696d652e4e6f7469667961006c756661215072696365206973206c6f776572207468616e2063757272656e74207072696365681553797374656d2e52756e74696d652e4e6f7469667961006c7566616a52c36a57c3a1644100215072696365206973206c6f776572207468616e2063757272656e74207072696365681553797374656d2e52756e74696d652e4e6f7469667961006c7566616a54c36a00c36a57c352726526fc647c006a53c30354505f6a51c37e6a00c35272681253797374656d2e53746f726167652e507574616a53c30650726963655f6a51c37e6a52c35272681253797374656d2e53746f726167652e507574610f726566756e64207375636365656421681553797374656d2e52756e74696d652e4e6f7469667961516c7566610d726566756e64206661696c6564681553797374656d2e52756e74696d652e4e6f7469667961006c7566006c756657c56b6a00527ac4681953797374656d2e53746f726167652e476574436f6e74657874616a51527ac46a51c36a00c37c681253797374656d2e53746f726167652e476574616a52527ac4096f776e6572206973206a52c37e681553797374656d2e52756e74696d652e4e6f74696679616a52c36c756660c56b6a00527ac46a51527ac46a52527ac4681953797374656d2e53746f726167652e476574436f6e74657874616a53527ac4682d53797374656d2e457865637574696f6e456e67696e652e476574457865637574696e6753637269707448617368616a54527ac46a53c36a51c37c681253797374656d2e53746f726167652e476574616a55527ac46a55c36a00c39c64a6006a53c30f4f726967696e616c5f4f776e65725f6a51c37e6a00c35272681253797374656d2e53746f726167652e507574616a53c30650726963655f6a51c37e6a52c35272681253797374656d2e53746f726167652e507574616a53c36a51c36a54c35272681253797374656d2e53746f726167652e507574610d73656c6c207375636365656421681553797374656d2e52756e74696d652e4e6f7469667961516c7566610b4e6f742061206f776e6572681553797374656d2e52756e74696d652e4e6f7469667961006c75665bc56b6a00527ac46a51527ac4681953797374656d2e53746f726167652e476574436f6e74657874616a52527ac46a52c36a51c37c681253797374656d2e53746f726167652e476574616351006a52c36a51c36a00c35272681253797374656d2e53746f726167652e50757461117265676973746572207375636365656421681553797374656d2e52756e74696d652e4e6f7469667961516c75666113616c7265616479207265676973746572656421681553797374656d2e52756e74696d652e4e6f7469667961006c75665ec56b6a00527ac46a51527ac46a51c36a00c3946a52527ac46a52c3c56a53527ac4006a54527ac46a00c36a55527ac461616a00c36a51c39f6433006a54c36a55c3936a56527ac46a56c36a53c36a54c37bc46a54c351936a54527ac46a55c36a54c3936a00527ac462c8ff6161616a53c36c7566' addr = Address.address_from_vm_code(code) abi = '{"functions":[{"name":"main","parameters":[{"name":"op","type":""},{"name":"args","type":""}],"returntype":""},{"name":"to_sc","parameters":[{"name":"acc","type":""},{"name":"acc1","type":""}],"returntype":""}]}' abi = json.loads(abi, object_hook=lambda d: namedtuple('X', d.keys()) (*d.values())) abi_info = AbiInfo('0x' + addr.to_reverse_hex_str(), 'Main', abi.functions, []) acc = sdk.get_wallet_manager().get_account( 'ANH5bHrrt111XwNEnuPZj6u95Dd6u7G4D6', '1') acc1 = sdk.get_wallet_manager().get_account( 'AazEvfQPcQ2GEFFPLF1ZLwQ7K5jDn81hve', '060708') func = abi_info.get_function('buy') func.set_params_value(acc1.get_address().to_byte_array(), 'zou', 2) res = sdk.neo_vm().send_transaction(addr.to_byte_array(), acc1, acc1, 200000000, 500, func, False) json_res = sdk.get_rpc().get_smart_contract_event_by_tx_hash(res) while json_res is None: json_res = sdk.get_rpc().get_smart_contract_event_by_tx_hash(res) time.sleep(1) print(json_res) print(res)
def test_native_invoke(self): """ 测试向合约打钱和从合约打钱给账户,使用以及功能 :return: """ code = '5dc56b6a00527ac46a51527ac46a00c305746f5f73639c6424006a51c300c36a52527ac46a51c351c36a53527ac46a52c36a53c37c6594016c7566616a00c30766726f6d5f73639c6424006a51c300c36a54527ac46a51c351c36a53527ac46a54c36a53c37c653c006c756661006c756656c56b6a00527ac46a51527ac46a52527ac46a00c36a51c36a52c353c66b6a52527ac46a51527ac46a00527ac46c6c75665cc56b6a00527ac46a51527ac41400000000000000000000000000000000000000016a52527ac4682d53797374656d2e457865637574696f6e456e67696e652e476574457865637574696e6753637269707448617368616a53527ac46a53c36a00c36a51c352726568ff6a54527ac4516a52c3087472616e736665726a54c351c176c9537951795572755172755279527954727552727568164f6e746f6c6f67792e4e61746976652e496e766f6b65616a55527ac46a55c3681553797374656d2e52756e74696d652e4e6f74696679616a55c3642f006a55c301019c6426000773756363656564681553797374656d2e52756e74696d652e4e6f746966796162230061066661696c6564681553797374656d2e52756e74696d652e4e6f746966796161006c75665dc56b6a00527ac46a51527ac41400000000000000000000000000000000000000016a52527ac4682d53797374656d2e457865637574696f6e456e67696e652e476574457865637574696e6753637269707448617368616a53527ac46a00c3681b53797374656d2e52756e74696d652e436865636b5769746e6573736164c9006a00c36a53c36a51c35272651dfe6a54527ac4516a52c3087472616e736665726a54c351c176c9537951795572755172755279527954727552727568164f6e746f6c6f67792e4e61746976652e496e766f6b65616a55527ac46a55c3681553797374656d2e52756e74696d652e4e6f74696679616a55c3642f006a55c301019c6426000773756363656564681553797374656d2e52756e74696d652e4e6f746966796162230061066661696c6564681553797374656d2e52756e74696d652e4e6f746966796161006c75665ec56b6a00527ac46a51527ac46a51c36a00c3946a52527ac46a52c3c56a53527ac4006a54527ac46a00c36a55527ac461616a00c36a51c39f6433006a54c36a55c3936a56527ac46a56c36a53c36a54c37bc46a54c351936a54527ac46a55c36a54c3936a00527ac462c8ff6161616a53c36c7566' addr = Address.address_from_vm_code(code) abi = '{"functions":[{"name":"Main","parameters":[{"name":"operation","type":""},{"name":"args","type":""}],"returntype":""},{"name":"to_sc","parameters":[{"name":"from_acct","type":""},{"name":"amount","type":""}],"returntype":""},{"name":"from_sc","parameters":[{"name":"to_acc","type":""},{"name":"amount","type":""}],"returntype":""},{"name":"makeState","parameters":[{"name":"fromacct","type":""},{"name":"toacct","type":""},{"name":"amount","type":""}],"returntype":""}]}' abi = json.loads(abi, object_hook=lambda d: namedtuple('X', d.keys()) (*d.values())) abi_info = AbiInfo('0x' + addr.to_reverse_hex_str(), 'Main', abi.functions, []) acc = sdk.get_wallet_manager().get_account( 'ANH5bHrrt111XwNEnuPZj6u95Dd6u7G4D6', '1') acc1 = sdk.get_wallet_manager().get_account( 'AazEvfQPcQ2GEFFPLF1ZLwQ7K5jDn81hve', '060708') print('acc: %s' % sdk.get_rpc().get_balance(acc.get_address_base58())) func = abi_info.get_function('to_sc') func.set_params_value(acc.get_address().to_byte_array(), 10) res = sdk.neo_vm().send_transaction(addr.to_byte_array(), acc, acc, 20000000000000, 500, func, False) json_res = sdk.get_rpc().get_smart_contract_event_by_tx_hash(res) while json_res is None: json_res = sdk.get_rpc().get_smart_contract_event_by_tx_hash(res) time.sleep(1) print(json_res) print(res) print('acc: %s' % sdk.get_rpc().get_balance(acc.get_address_base58())) print() func = abi_info.get_function('from_sc') func.set_params_value(acc.get_address().to_byte_array(), 10) res = sdk.neo_vm().send_transaction(addr.to_byte_array(), acc, acc, 20000000000000, 500, func, False) json_res = sdk.get_rpc().get_smart_contract_event_by_tx_hash(res) while json_res is None: json_res = sdk.get_rpc().get_smart_contract_event_by_tx_hash(res) time.sleep(1) print(json_res) print(res) print('acc: %s' % sdk.get_rpc().get_balance(acc.get_address_base58()))
def test_no_param(self): code = '57c56b6a00527ac46a51527ac46a00c304746573749c640900650b006c756661006c756653c56b06726573756c746c7566' addr = Address.address_from_vm_code(code) abi = '{"functions":[{"name":"Main","parameters":[{"name":"op","type":""},{"name":"args","type":""}],"returntype":""},{"name":"test","parameters":[{"name":"","type":""}],"returntype":""}]}' abi = json.loads(abi, object_hook=lambda d: namedtuple('X', d.keys()) (*d.values())) abi_info = AbiInfo('0x' + addr.to_reverse_hex_str(), 'Main', abi.functions, []) acc = sdk.get_wallet_manager().get_account( 'ANH5bHrrt111XwNEnuPZj6u95Dd6u7G4D6', '1') func = abi_info.get_function('test') func.set_params_value() res = sdk.neo_vm().send_transaction(addr.to_byte_array(), acc, acc, 200000000, 500, func, True) print(bytes.fromhex(res).decode())
def test_use_hash(self): code = '59c56b6a00527ac46a51527ac46a00c304746573749c6409006a51c3652700616a00c30574657374319c640900650b006c756661006c756653c56b04746573746c75660116c56b6a00527ac401610162016353c176c96a51527ac4681653797374656d2e52756e74696d652e47657454696d65616a52527ac4526a53527ac4556a54527ac46a53c36a54c3966a55527ac46a55c3681553797374656d2e52756e74696d652e4e6f74696679616a52c36a56527ac46a56c353976a56527ac46a56c300876426006a51c36a56c3c3681553797374656d2e52756e74696d652e4e6f7469667961006c7566616a56c351876426006a51c36a56c3c3681553797374656d2e52756e74696d652e4e6f7469667961006c7566616a56c3529c6424006a51c352c3681553797374656d2e52756e74696d652e4e6f7469667961006c7566616a56c3681553797374656d2e52756e74696d652e4e6f746966796151681553797374656d2e52756e74696d652e4e6f7469667961006c75665ec56b6a00527ac46a51527ac46a51c36a00c3946a52527ac46a52c3c56a53527ac4006a54527ac46a00c36a55527ac461616a00c36a51c39f6433006a54c36a55c3936a56527ac46a56c36a53c36a54c37bc46a54c351936a54527ac46a55c36a54c3936a00527ac462c8ff6161616a53c36c7566' abi = '{"functions":[{"name":"main","parameters":[{"name":"op","type":""},{"name":"args","type":""}],"returntype":""},{"name":"test","parameters":[{"name":"args","type":""}],"returntype":""},{"name":"test1","parameters":[{"name":"","type":""}],"returntype":""}]}' addr = Address.address_from_vm_code(code) abi = json.loads(abi) abi_info = AbiInfo('0x' + addr.to_reverse_hex_str(), 'main', abi['functions'], []) acc = sdk.get_wallet_manager().get_account( 'ANH5bHrrt111XwNEnuPZj6u95Dd6u7G4D6', '1') func = abi_info.get_function('test') func.set_params_value((addr.to_reverse_hex_str(), )) res = sdk.neo_vm().send_transaction(addr.to_array(), acc, acc, 200000000, 500, func, False) json_res = sdk.get_rpc().get_smart_contract_event_by_tx_hash(res) while json_res is None: json_res = sdk.get_rpc().get_smart_contract_event_by_tx_hash(res) time.sleep(1) print(json_res) print(res)
from ontology.smart_contract.neo_contract.abi.abi_info import AbiInfo from ontology.utils import util import time import json # ------------------------------------------- # GLOBAL SETTINGS # ------------------------------------------- rpc_addr = 'http://polaris3.ont.io:20336' sdk = OntologySdk() sdk.set_rpc(rpc_addr) sdk.open_wallet('/Users/zou/PycharmProjects/ont_test/ont_contrast/demo/cli/wallet.json') code = '' addr = Address.address_from_vm_code(code) contract_addr = addr.to_array() abi = '{"functions":[{"name":"main","parameters":[{"name":"op","type":""},{"name":"args","type":""}],"returntype":""},{"name":"init","parameters":[{"name":"seed","type":""}],"returntype":""},{"name":"next_round","parameters":[{"name":"seed","type":""}],"returntype":""},{"name":"shoot","parameters":[{"name":"off_player","type":""},{"name":"def_player","type":""},{"name":"seconds","type":""},{"name":"team","type":""}],"returntype":""},{"name":"pass_ball","parameters":[{"name":"holder","type":""},{"name":"def_player","type":""},{"name":"team","type":""}],"returntype":""},{"name":"get_scores","parameters":[{"name":"","type":""}],"returntype":""},{"name":"get_curr_time","parameters":[{"name":"","type":""}],"returntype":""},{"name":"get_team_scores","parameters":[{"name":"","type":""}],"returntype":""},{"name":"pick_ball_holder","parameters":[{"name":"team","type":""},{"name":"is_first","type":""}],"returntype":""},{"name":"jump_ball","parameters":[{"name":"","type":""}],"returntype":""},{"name":"rand_player","parameters":[{"name":"team","type":""}],"returntype":""},{"name":"random_int_from_zero","parameters":[{"name":"num","type":""},{"name":"seed","type":""}],"returntype":""}]}' abi = json.loads(abi) abi_info = AbiInfo('0x' + addr.to_reverse_hex_str(), 'main', abi['functions'], []) acc1 = sdk.get_wallet_manager().get_account('ANH5bHrrt111XwNEnuPZj6u95Dd6u7G4D6', '1') def get_from_hex(res): """ hex to string :param res: :return: """
sdk.open_wallet( '/Users/zou/PycharmProjects/ont_test/ont_contrast/demo/cli/wallet.json') acc1 = sdk.get_wallet_manager().get_account( 'ANH5bHrrt111XwNEnuPZj6u95Dd6u7G4D6', '1') acc2 = sdk.get_wallet_manager().get_account( 'AYvTfgEyYduk3zEKMDnZggWQqt9bkASNxJ', '060708') acc3 = sdk.get_wallet_manager().get_account( 'AazEvfQPcQ2GEFFPLF1ZLwQ7K5jDn81hve', '060708') pub_keys = [ acc1.get_public_key(), acc2.get_public_key(), acc3.get_public_key() ] multi_addr = Address.address_from_multi_pubKeys(2, pub_keys) class TestSDK(TestCase): def test_multi_sig_transaction(self): print('账户1余额:%s' % sdk.get_rpc().get_balance(acc1.get_address_base58())['ont']) tx = sdk.native_vm().asset().new_transfer_transaction( "ont", acc1.get_address_base58(), multi_addr.b58encode(), 100, acc1.get_address_base58(), 200000, 500) sdk.add_sign_transaction(tx, acc1) txid = sdk.get_rpc().send_raw_transaction(tx) time.sleep(2) print('账户1给多签地址打钱,交易ID:%s' % txid) balance_acc1 = sdk.get_rpc().get_balance(acc1.get_address_base58()) balance_multi = sdk.get_rpc().get_balance(multi_addr.b58encode())