コード例 #1
0
def send_grams(address: str):
    giver_abi = Abi.from_json_path(
        path=os.path.join(SAMPLES_DIR, 'Giver.abi.json'))
    call_set = CallSet(function_name='grant', inputs={'addr': address})
    async_core_client.processing.process_message(abi=giver_abi,
                                                 signer=Signer(),
                                                 address=GIVER_ADDRESS,
                                                 call_set=call_set,
                                                 send_events=False)
コード例 #2
0
 def get_testnet_grams(self,address: str):
     giver_abi = Abi.from_json_path(
         path=os.path.join(self.SAMPLES_DIR, 'Giver.abi.json'))
     call_set = CallSet(
         function_name='grant',
         inputs={'addr': address})
     self.async_core_client.processing.process_message(
         abi=giver_abi, signer=Signer(), address='0:653b9a6452c7a982c6dc92b2da9eba832ade1c467699ebb3b43dca6d77b780dd',
         call_set=call_set, send_events=False)
コード例 #3
0
 def send_data(self,function_name,inputs,outputs):
     with open(".contract.abi.json") as f:
         data = json.loads(f.read())
     sender = {}
     for i in inputs:
         for x in data["functions"]:
             if x["name"] == function_name:
                 for t in x["inputs"]:
                     if t["name"] == i[0]:
                         if "int" in t["type"]:
                             sender[i[0]] = int(i[1].text())
                         else:
                             sender[i[0]] = i[1].text()
     #m = QMessageBox.about(self, "Running...", "Please wait for a while. Dont press any button")
     print(self.addr,Abi.from_json_path(
         path='.contract.abi.json'),function_name,sender,Signer(self.main_key))
     response = self.wrapper.run_contract(self.addr,Abi.from_json_path(
         path='.contract.abi.json'),function_name,sender,signer=Signer(self.main_key))
     QMessageBox.about(self, "Running...", str(response))
コード例 #4
0
    def compile_contract(self):
        if not ".tmp_contract_deployer" in os.listdir():
            os.mkdir(".tmp_contract_deployer")
        f = open(f'.tmp_contract_deployer/.contract.sol','w')
        f.write(self.plainTextEdit.toPlainText())
        f.close()

        home_dir = os.system("solc .tmp_contract_deployer/.contract.sol")
        os.system("tvm_linker compile .contract.code --abi-json .contract.abi.json --lib stdlib_sol.tvm -o .contract.tvc")
        with open(".contract.abi.json","r") as f:
            abi = f.read()
        addr = self.wrapper.get_address(Signer(self.main_key),Abi.from_json_path(
            path='.contract.abi.json'),self.wrapper.open_tvc(".contract.tvc"))
        self.address.setText(QCoreApplication.translate("MainWindow", f"Address of contract: {addr}", None))
        self.addr = addr
        self.update_balance()
        with open(".contract.abi.json") as f:
            data = json.loads(f.read())

        self.create_function(data)
コード例 #5
0
 def compile(self):
     m = QMessageBox.about(self,"Deploying...","Please wait for a while. Dont press any button")
     result = self.wrapper.deploy_contract(abi=Abi.from_json_path(
         path='.contract.abi.json'),tvc=self.wrapper.open_tvc('.contract.tvc'),signer=Signer(self.main_key))
     m.setText(str(result))
コード例 #6
0
 def run_contract(self,address: str, abi: Abi, function_name: str, inputs: dict, signer=Signer()):
     call_set = CallSet(
         function_name=function_name,
         inputs=inputs)
     encoded = self.async_core_client.abi.encode_message(
         abi=abi, signer=signer, address=address,
         call_set=call_set)
     shard_block_id = self.async_core_client.processing.send_message(
         message=encoded["message"], send_events=False)
     return self.async_core_client.processing.wait_for_transaction(encoded['message'], shard_block_id, send_events=False,
                                                              abi=abi)