def test_normal_003_consensus(self): process = False try: storage_key = ByteToHex(b'Test Key 03') storage_value = ByteToHex(b'Test Value 03') (process, response) = API.contract().invoke_function( test_config.m_contract_addr, "auth_put", Config.ontID_B, "1", argvs=[{ "type": "bytearray", "value": storage_key }, { "type": "bytearray", "value": storage_value }]) self.ASSERT(process, "invoke_function put error...") API.node().wait_gen_block() (process, response) = API.contract().invoke_function( test_config.m_contract_addr, "get", Config.ontID_B, "1", argvs=[{ "type": "bytearray", "value": storage_key }]) self.ASSERT(response["result"]["Result"] == '', "invoke_function get error...") except Exception as e: logger.print(e.args[0])
def test_normal_015_consensus(self): process = False try: storage_key = ByteToHex(b'Test Key 15') storage_value = ByteToHex(b'Test Value 15') (process, response) = API.contract().invoke_function( test_config.m_contract_addr, "put", "", "1", argvs=[{ "type": "bytearray", "value": storage_key }, { "type": "bytearray", "value": storage_value }], node_index=test_config.m_current_node) self.ASSERT(process, "invoke_function put error...") (process, response) = API.contract().invoke_function( test_config.m_contract_addr, "get", "", "1", argvs=[{ "type": "bytearray", "value": storage_key }], node_index=test_config.m_current_node) self.ASSERT(process, "invoke_function get error...") except Exception as e: logger.print(e.args[0])
def test_init(self): for node_index in range(len(Config.NODES)): API.node().stop_nodes([node_index]) API.node().start_nodes([0, 1, 2, 3, 4, 5, 6], Config.DEFAULT_NODE_ARGS, True, True, config="config-dbft.json") #start_nodes([0,1,2,3,4,5,6], Config.DEFAULT_NODE_ARGS, True, True) for node_index in range(7): API.native().regid_with_publickey(node_index) API.native().init_ont_ong() (test_config.m_contract_addr, test_config.m_contract_txhash) = API.contract().deploy_contract_full( test_config.deploy_neo_1, test_config.name1, test_config.desc, test_config.price) (test_config.m_contract_addr2, test_config.m_contract_txhash2) = API.contract().deploy_contract_full( test_config.deploy_neo_2, test_config.name1, test_config.desc, test_config.price) #A节点是Admin节点 (process, response) = API.contract().init_admin(test_config.m_contract_addr, Config.ontID_A) time.sleep(6) (process, response) = API.native().bind_role_function( test_config.m_contract_addr, Config.ontID_A, Config.roleA_hex, ["auth_put"])
def set_premise_a(neo_path_a, neo_path_b): result = False contract_address = None # 初始化合约B管理员为A用户, contract_address_B = API.contract().deploy_contract(neo_path_b) # 部署智能合约A contract_address_A = API.contract().deploy_contract(neo_path_a) time.sleep(5) (result, response) = API.contract().init_admin(contract_address_B, Config.ontID_A) if not result: raise (Error("init_admin error")) # 用户A创建角色A (result, response) = API.native().bind_role_function( contract_address_B, Config.ontID_A, Config.roleA_hex, ["contractB_Func_A"]) if not result: raise (Error("bind_role_function error [1]")) # setp 1 用户A绑定角色A (result, response) = API.native().bind_user_role( contract_address_B, Config.ontID_A, Config.roleA_hex, [Config.ontID_A]) if not result: raise (Error("bind_user_role error")) if result: return (contract_address_A, contract_address_B) else: raise (Error("set_premise error"))
def init_bft_node(self, bft_index): API.node().stop_all_nodes() API.node().start_nodes([0, 1, 2, 3, 4], Config.DEFAULT_NODE_ARGS, True, True, program="ontology") logger.info("start bft node: " + "ontology-bft_" + str(bft_index)) API.node().start_nodes([5, 6], Config.DEFAULT_NODE_ARGS, True, True, program="ontology-bft_" + str(bft_index)) for node_index in range(7): API.native().regid_with_publickey(node_index) API.native().init_ont_ong() (test_config.m_contract_addr, test_config.m_contract_txhash) = API.contract().deploy_contract_full( test_config.deploy_neo_1, test_config.name1, test_config.desc, test_config.price) (test_config.m_contract_addr2, test_config.m_contract_txhash2) = API.contract().deploy_contract_full( test_config.deploy_neo_2, test_config.name1, test_config.desc, test_config.price)
def test_normal_005_consensus(self): process = False try: storage_key = ByteToHex(b'Test Key 05') storage_value = ByteToHex(b'Test Value 05') (process, response) = API.contract().invoke_function( test_config.m_contract_addr, "put", "", "1", argvs=[{ "type": "bytearray", "value": storage_key }, { "type": "bytearray", "value": storage_value }], node_index=test_config.m_current_node) self.ASSERT(process, "invoke_function put error...") API.node().wait_gen_block() (process, response) = API.contract().invoke_function( test_config.m_contract_addr2, "get", "", "1", argvs=[{ "type": "bytearray", "value": storage_key }], node_index=test_config.m_current_node) self.ASSERT(process, "invoke_function get error...[1]") self.ASSERT(response["result"]["Result"] != storage_value, "invoke_function get error...[2]") except Exception as e: logger.print(e.args[0])
def set_premise_b(neo_path): result = False contract_address = API.contract().deploy_contract(neo_path) time.sleep(5) (result, response) = API.contract().init_admin(contract_address, Config.ontID_A) if not result: raise (Error("init_admin error")) (result, response) = API.native().bind_role_function( contract_address, Config.ontID_A, Config.roleA_hex, ["transfer", "approve", "transferFrom", "allowance", "balanceOf"]) if not result: raise (Error("bind_role_function error [1]")) # setp 1 用户A绑定角色A (result, response) = API.native().bind_user_role( contract_address, Config.ontID_A, Config.roleA_hex, [Config.ontID_A]) if not result: raise (Error("bind_user_role error")) if result: return contract_address else: raise (Error("set_premise error"))
def test_init(self): API.node().stop_all_nodes() API.node().start_nodes([0, 1, 2, 3, 4, 5, 6], Config.DEFAULT_NODE_ARGS, True, True) API.node().wait_gen_block() API.node().wait_gen_block() (test_config.m_contractaddr_right, test_config.m_txhash_right) = API.contract().deploy_contract_full( testpath + "/resource/A.neo", "name", "desc", 0) API.node().wait_gen_block() test_config.m_getstorage_contract_addr = test_config.m_contractaddr_right (result, response) = API.rpc().getblockhash(height=1) test_config.m_block_hash_right = response["result"] (result, response) = API.contract().sign_transction( Task(testpath + "/resource/cli/siginvoketx.json"), False) test_config.m_signed_txhash_right = response["result"]["signed_tx"] test_config.m_signed_txhash_wrong = test_config.m_signed_txhash_right + "0f0f0f0f" test_config.m_getstorage_contract_addr_wrong = test_config.m_contractaddr_right + "0f0f0f0f" API.contract().invoke_function( test_config.m_contractaddr_right, "put", "", "1", argvs=[{ "type": "bytearray", "value": test_config.m_getstorage_contract_key }, { "type": "bytearray", "value": test_config.m_getstorage_contract_value }], node_index=0)
class test_config(): node_index = 5 nodePath = "/home/ubuntu/ontology/node" contract_address = API.contract().deploy_contract("resource/ont_neo.json") pay_address = Config.NODES[node_index]["address"] get_address = Config.NODES[2]["address"] amount = "10" sender = Config.NODES[2]["address"] sender_node = 2 senderType = False from1 = pay_address #from_正确的from值_正常 from2 = "1111111111111111111111111111" #from_错误的from值(参数不正确)_异常 from3 = "" #from_留空_异常 to1 = get_address #to_正确的to值_正常 to2 = from2 #to_错误的to值_异常 to3 = "" #to_留空_异常 amount1 = "10" #amount_正确的数量10_正常 amount2 = "0" #amount_正确的数量0_正常 amount3 = "-1" #amount_错误的数量(-1)_异常 amount4 = "2000000000000" #amount_错误的数量(from账户不存在这么多数量的ont)_异常 amount5 = "abc" #amount_错误的数量(abc)_异常 amount6 = "" #amount_错误的数量(留空)_异常 from4 = from2 #from_错误的from值_异常 sender1 = to1 #sender_正确的sender值(被授权的账户地址)_正常 sender1_node = 2 sender1Type = senderType sender2 = contract_address #sender_正确的sender值(被授权的智能合约地址)_正常 sender2_node = 2 sender2Type = True sender3 = from1 #sender_正确的sender值(from账户地址)_正常 sender3_node = 2 sender3Type = False sender4 = "ANdtbPPwfMv79eMev9z7aAZRM6bUuQQ3rf" #sender_错误的sender值(未被授权的账户地址)_异常 sender4_node = 2 sender4Type = False sender5 = API.contract().deploy_contract( "resource/ontErr.json") #sender_错误的sender值(未被授权的智能合约地址)_异常 sender5_node = 2 sender5Type = True sender6 = "abc" #sender_错误的sender值(abc)_异常 sender6Type = False sender6_node = 2 sender7 = "" #sender_留空_异常 sender7_node = 2 sender7Type = False from5 = from1 #from_正确的from值(账户存在)_正常 from6 = "ASK6GGsZfPf8WfSYhWUhw7SaZxnZ111111" #from_错误的from值(账户不存在)_异常 to4 = to1 #to_正确的to值(账户存在)_正常 to5 = from6 #to_错误的to值(账户不存在)_异常 amount7 = "10" #amount_正确的数量10_异常 address1 = from1 #address_正确的address值_正常 address2 = from2 #address_错误的address值_异常 address3 = "" #address_留空_异常 from7 = from1 #from_正确的from值_异常 sender8 = to1 #sender_正确的sender值(被授权的账户地址)_异常 sender8_node = 5 sender8Type = False address4 = from1 #address_正确的address值_异常
def test_abnormal_012_consensus(self): process = False try: storage_key = ByteToHex(b'Test Key 12') storage_value = ByteToHex(b'Test Value 12') for i in range(1, 4): self.init_bft_node(i) API.node().wait_gen_block() time.sleep(5) #A节点是Admin节点 (process, response) = API.contract().init_admin( test_config.m_contract_addr, Config.ontID_A, sleep=0) self.ASSERT(process, "init_admin error...") API.node().wait_gen_block() time.sleep(2) (process, response) = API.native().bind_role_function( test_config.m_contract_addr, Config.ontID_A, Config.roleA_hex, ["auth_put"], sleep=0) self.ASSERT(process, "bind_role_function error...") API.node().wait_gen_block() time.sleep(2) (process, response) = API.contract().invoke_function( test_config.m_contract_addr, "auth_put", Config.ontID_B, "1", argvs=[{ "type": "bytearray", "value": storage_key }, { "type": "bytearray", "value": storage_value }], sleep=0) self.ASSERT(process, "invoke_function put error...") API.node().wait_gen_block() time.sleep(2) (process, response) = API.contract().invoke_function( test_config.m_contract_addr, "get", Config.ontID_B, "1", argvs=[{ "type": "bytearray", "value": storage_key }]) self.ASSERT(response["result"]["Result"] == '', "invoke_function get error...") except Exception as e: logger.print(e.args[0])
def changeRecovery(ontId, new_recovery_address, old_recovery_address, public_key, node_index=None, errorcode=47001, old_recovery_address_Array=[], errorkey="error"): request = { "REQUEST": { "Qid": "t", "Method": "signativeinvoketx", "Params": { "gas_price": 0, "gas_limit": 1000000000, "method": "changeRecovery", "address": "0300000000000000000000000000000000000000", "version": 1, "params": [ ontId, Common.bl_reserver(new_recovery_address), Common.bl_reserver(old_recovery_address) ] } }, "RESPONSE": { errorkey: errorcode } } if (errorkey == "error_code"): request["SIGN_RESPONSE"] = {errorkey: errorcode} if node_index != None: request["NODE_INDEX"] = node_index else: node_index = Config.ontid_map[public_key] request["NODE_INDEX"] = node_index if len(old_recovery_address_Array ) == 0 or len(old_recovery_address_Array) > 2: return API.contract().call_contract(Task(name="changeRecovery", ijson=request), twice=True, sleep=2) else: return API.contract().call_multisig_contract( Task(name="changeRecovery", ijson=request), old_recovery_address_Array[0], old_recovery_address_Array[1])
def addKey(ontId, new_public_key, public_key, node_index=None, errorcode=47001, public_key_Array=[]): request = { "REQUEST": { "Qid": "t", "Method": "signativeinvoketx", "Params": { "gas_price": 0, "gas_limit": 1000000000, "method": "addKey", "address": "0300000000000000000000000000000000000000", "version": 1, "params": [ontId, new_public_key, public_key] } }, "RESPONSE": { "error": errorcode } } if node_index != None: request["NODE_INDEX"] = node_index else: node_index = Config.ontid_map[public_key] request["NODE_INDEX"] = node_index if len(public_key_Array) == 0 or len(public_key_Array) > 2: return API.contract().call_contract(Task(name="addKey", ijson=request), twice=True) else: return multi_contract(Task(name="addKey", ijson=request), public_key_Array[0], public_key_Array[1])
def regIDWithPublicKey(ontId, public_key, node_index=None, errorcode=47001): request = { "REQUEST": { "Qid": "t", "Method": "signativeinvoketx", "Params": { "gas_price": 0, "gas_limit": 1000000000, "method": "regIDWithPublicKey", "address": "0300000000000000000000000000000000000000", "version": 1, "params": [ontId, public_key] } }, "RESPONSE": { "error": errorcode } } if node_index != None: request["NODE_INDEX"] = node_index else: node_index = Config.ontid_map[public_key] request["NODE_INDEX"] = node_index return API.contract().call_contract(Task(name="regIDWithPublicKey", ijson=request), twice=True)
def invoke_function_TransferPenalty(func_, pubKey, walletAddress, errorcode=0, errorkey="error"): request = { "NODE_INDEX": 0, "REQUEST": { "Qid": "t", "Method": "signativeinvoketx", "Params": { "gas_price": 0, "gas_limit": 1000000000, "address": "0700000000000000000000000000000000000000", "method": func_, "version": 0, "params": [pubKey, walletAddress] } }, "RESPONSE": { "error": errorcode } } if (errorkey == "error_code"): request["SIGN_RESPONSE"] = {errorkey: errorcode} return API.contract().call_multisig_contract( Task(name="invoke_function_TransferPenalty", ijson=request), Config.AdminNum, Config.AdminPublicKeyList)
def native_transfer_multi(pay_address, get_address, amount, node_index=None, errorcode=0): amount = amount * 1000000000 request = { "REQUEST": { "Qid": "t", "Method": "signativeinvoketx", "Params": { "gas_price": 0, "gas_limit": 1000000000, "address": "0100000000000000000000000000000000000000", "method": "transfer", "version": 1, "params": [[pay_address, get_address, str(amount)]] } }, "RESPONSE": { "error": errorcode }, } return API.contract().call_contract(Task(name="transfer", ijson=request), twice=True) #InResponse={} #getStorageVoteInfo(Config.NODES[0]["pubkey"],Config.NODES[7]["address"]) #getStorageVoteInfo(Config.NODES[0]["pubkey"],Config.NODES[7]["address"]) #nodeCountCheck(InResponse,7) #getStorageConf("vbftConfig") #getStorageConf("globalParam") #getStorageConf("splitCurve")
def invoke_function_register(func_, pubKey, walletAddress, ontCount, ontID, user, errorcode=0): request = { "NODE_INDEX": 7, "REQUEST": { "Qid": "t", "Method": "signativeinvoketx", "Params": { "gas_price": 0, "gas_limit": 1000000000, "address": "0700000000000000000000000000000000000000", "method": func_, "version": 0, "params": [pubKey, walletAddress, ontCount, ontID, user] } }, "RESPONSE": { "error": errorcode } } return API.contract().call_contract(Task(name="invoke_function_register", ijson=request), twice=True)
def invoke_function_quitNode(func_, pubKey, walletAddress, node_index=None, errorcode=0): request = { "NODE_INDEX": node_index, "REQUEST": { "Qid": "t", "Method": "signativeinvoketx", "Params": { "gas_price": 0, "gas_limit": 1000000000, "address": "0700000000000000000000000000000000000000", "method": func_, "version": 0, "params": [pubKey, walletAddress] } }, "RESPONSE": { "error": errorcode } } return API.contract().call_contract(Task(name="invoke_function_quitNode", ijson=request), twice=True)
def test_normal_004_consensus(self): process = False try: storage_key = ByteToHex(b'Test Key 04') storage_value = ByteToHex(b'Test Value 04') (process, response) = API.contract().invoke_function( test_config.m_contract_addr, "put", "", "1", argvs=[{ "type": "bytearray", "value": storage_key }, { "type": "bytearray", "value": storage_value }], node_index=test_config.m_current_node) self.ASSERT(process, "invoke_function put error...") API.node().wait_gen_block() process = API.node().check_node_state([0, 1, 2, 3, 4, 5, 6]) self.ASSERT(process, "") except Exception as e: logger.print(e.args[0])
def totalSupply(contract_address,node_index = None,errorcode=47001): request = { "REQUEST": { "Qid": "t", "Method": "signeovminvoketx", "Params": { "gas_price": 0, "gas_limit": 1000000000, "address": contract_address, "version": 1, "params": [ { "type": "string", "value": "totalSupply" }, { "type": "string", "value": "name" } ] } }, "RESPONSE":{"error" : errorcode}, "NODE_INDEX":node_index } return API.contract().call_contract(Task(name="totalSupply", ijson=request), twice = True,sleep=0)
def test_init(self): time.sleep(2) print("stop all") API.node().stop_all_nodes() print("start all") API.node().start_nodes([0,1,2,3,4,5,6], Config.DEFAULT_NODE_ARGS, True, True) time.sleep(60) print("waiting for 60s......") (test_config.contract_addr, test_config.contract_tx_hash) = API.contract().deploy_contract_full(testpath+"/resource/test.neo") API.node().wait_gen_block() test_config.CONTRACT_ADDRESS_CORRECT = test_config.contract_addr test_config.CONTRACT_ADDRESS_INCORRECT_2 = test_config.contract_addr + "11" test_config.TX_HASH_CORRECT = test_config.contract_tx_hash test_config.TX_HASH_INCORRECT_2 = test_config.contract_tx_hash[:-2] test_config.TX_HASH_INCORRECT_3 = test_config.contract_tx_hash + "1111" test_config.block_height = int(API.rpc().getblockcount()[1]["result"]) - 1 test_config.block_hash = API.rpc().getblockhash(test_config.block_height - 1)[1]["result"] test_config.signed_data = get_signed_data() test_config.HEIGHT_CORRECT = test_config.block_height - 1 test_config.HEIGHT_INCORRECT_2 = test_config.block_height + 1000 test_config.BLOCK_HASH_CORRECT = test_config.block_hash test_config.BLOCK_HASH_INCORRECT_2 = test_config.block_hash[:-2] # HASH NOT EXISTENT test_config.BLOCK_HASH_INCORRECT_3 = test_config.block_hash + "1111" test_config.RAW_TRANSACTION_DATA_CORRECT = test_config.signed_data test_config.RAW_TRANSACTION_DATA_INCORRECT_2 = "11111111" + test_config.signed_data + "1111111111"
def test_normal_010_consensus(self): try: process = False storage_key = ByteToHex(b'Test Key 10') storage_value = ByteToHex(b'Test Value 10') for i in range(1, 4): self.init_bft_node(i) API.node().wait_gen_block() time.sleep(5) (process, response) = API.contract().invoke_function( test_config.m_contract_addr, "put", "", "1", argvs=[{ "type": "bytearray", "value": storage_key }, { "type": "bytearray", "value": storage_value }], node_index=test_config.m_current_node, sleep=0) API.node().wait_gen_block() time.sleep(5) self.ASSERT(process, "invoke_function error...") (process, response) = API.rpc().getblockheightbytxhash( response["txhash"]) self.ASSERT(process, "not a valid block...") except Exception as e: logger.print(e.args[0])
def test_normal_013_consensus(self): process = False try: storage_key = ByteToHex(b'Test Key 13') storage_value = ByteToHex(b'Test Value 13') for i in range(1, 4): self.init_bft_node(i) time.sleep(30) for j in range(10): (process, response) = API.contract().invoke_function( test_config.m_contract_addr, "put", "", "1", argvs=[{ "type": "bytearray", "value": storage_key }, { "type": "bytearray", "value": storage_value }], node_index=test_config.m_current_node) self.ASSERT(process, "invoke_function put error...") API.node().wait_gen_block() except Exception as e: logger.print(e.args[0])
def getDDO(ontId, public_key, node_index=None, errorcode=47001, errorkey="error"): request = { "REQUEST": { "Qid": "t", "Method": "signativeinvoketx", "Params": { "gas_price": 0, "gas_limit": 1000000000, "method": "getDDO", "address": "0300000000000000000000000000000000000000", "version": 1, "params": [ontId] } }, "RESPONSE": { errorkey: errorcode } } if (errorkey == "error_code"): request["SIGN_RESPONSE"] = {errorkey: errorcode} if node_index != None: request["NODE_INDEX"] = node_index else: node_index = Config.ontid_map[public_key] request["NODE_INDEX"] = node_index return API.contract().call_contract(Task(name="getDDO", ijson=request), twice=True, sleep=2)
def invoke_contract_migrate(contract_address, script_hash, name, version, author, email, desc, node_index=None, sleep=5): request = { "REQUEST": { "Qid": "t", "Method": "signeovminvoketx", "Params": { "gas_price": 0, "gas_limit": 1000000000, "address": contract_address, "version": 1, "params": [{ "type": "string", "value": "GetContract_Migrate" }, { "type": "array", "value": [{ "type": "bytearray", "value": script_hash }, { "type": "bool", "value": "true" }, { "type": "string", "value": name }, { "type": "string", "value": version }, { "type": "string", "value": author }, { "type": "string", "value": email }, { "type": "string", "value": desc }] }] } }, "RESPONSE": {} } return API.contract().call_contract(Task(name="GetContract_Migrate", ijson=request), twice=True, sleep=sleep)
def transfer(): request = { "REQUEST": { "Qid": "t", "Method": "signativeinvoketx", "Params": { "gas_price": 0, "gas_limit": 1000000000, "method": "transfer", "address": "0100000000000000000000000000000000000000", "version": 1, "params": [[[ "AZKG25z2yjCUTQZtNYb9Pq4dezP4zGRFsP", "AS9S7j6VWUgg3sX89pok6KHeYU9DenKwbS", "100" ]]] } }, "RESPONSE": { "error": 0 } } return API.contract( ).call_multisig_contract(Task(name="transfer", ijson=request), 3, [ "031b7025752886d5598e3a165a7ba4accc770955e4450ee5e14d38d35c7dfef8a5", "03b36e26db8b132b551a0213ade4eeb39510847acd152490ef170604c5e4e4686d", "03f8d89ab17423d9e4a57b7e7174bcf239eb42779fd942b0601b778087440d35aa" ])
def invoke_function_vote(func_, walletAddress, voteList, voteCount, errorcode=0, node_index=None): request = { "REQUEST": { "Qid": "t", "Method": "signativeinvoketx", "Params": { "gas_price": 0, "gas_limit": 1000000000, "address": "0700000000000000000000000000000000000000", "method": func_, "version": 0, "params": [walletAddress, voteList, voteCount] } }, "RESPONSE": { "error": errorcode } } if node_index != None: request["NODE_INDEX"] = node_index return API.contract().call_contract(Task(name="invoke_function_vote", ijson=request), twice=True)
def native_transfer_ont(pay_address, get_address, amount, node_index=0, errorcode=0): request = { "REQUEST": { "Qid": "t", "Method": "signativeinvoketx", "Params": { "gas_price": 0, "gas_limit": 1000000000, "address": "0100000000000000000000000000000000000000", "method": "transfer", "version": 1, "params": [[[pay_address, get_address, amount]]] } }, "RESPONSE": { "error": errorcode }, "NODE_INDEX": node_index } return API.contract().call_contract(Task(name="transfer", ijson=request), twice=True)
def transferFrom1(contract_address,sender,pay_address,get_address, amount,node_index = None,senderType=False,errorcode=47001,errorkey="error"): request = { "REQUEST": { "Qid": "t", "Method": "signativeinvoketx", "Params": { "gas_price": 0, "gas_limit": 1000000000, "address": "0200000000000000000000000000000000000000", "method": "transferFrom", "version": 1, "params": [ sender, pay_address, get_address, amount ] } }, "RESPONSE":{"error" : errorcode}, "NODE_INDEX":node_index } if (errorkey =="error_code"): request["SIGN_RESPONSE"]={errorkey : errorcode} return API.contract().call_contract(Task(name="transferFrom", ijson=request), twice = True,sleep=0)
def invoke_function_opCode(contract_address, function_str, param_1, param_2, sleep=0): request = { "REQUEST": { "Qid": "t", "Method": "signeovminvoketx", "Params": { "gas_price": 0, "gas_limit": 1000000000, "address": contract_address, "version": 1, "params": [ { "type": "string", "value": function_str }, { "type": "array", "value": [ { "type": "int", "value": param_1 }, { "type": "int", "value": param_2 } ] } ] } }, "RESPONSE":{"error" : 0} } return API.contract().call_contract(Task(name="invoke_function_opCode", ijson=request), twice = True, sleep=sleep)
def get_height(contract_address, node_index=None): request = { "REQUEST": { "Qid": "t", "Method": "signeovminvoketx", "Params": { "gas_price": 0, "gas_limit": 1000000000, "address": contract_address, "version": 0, "params": [{ "type": "string", "value": "GetHeight" }, { "type": "array", "value": [{ "type": "string", "value": "" }] }] } }, "RESPONSE": {} } return API.contract().call_contract(Task(name="GetHeight", ijson=request), twice=True)