def _call_tx(self, owner, to, method, params, limit, value: int = 0): transaction = CallTransactionBuilder() \ .from_(owner.get_address()) \ .to(to) \ .step_limit(limit) \ .version(3) \ .nid(self._nid) \ .method(method) \ .params(params) \ .value(value) \ .build() ret = self._call_on_send_request(transaction.to_dict()) if not ret: return return self._icon_service.send_transaction(SignedTransaction(transaction, owner), full_response=True)
def _call_tx(self, owner, to, method, params, value: int = 0): transaction = CallTransactionBuilder() \ .from_(owner.get_address()) \ .to(to) \ .version(3) \ .nid(self._nid) \ .method(method) \ .params(params) \ .value(value) \ .build() ret = self._call_on_send_request(transaction.to_dict()) if not ret: return step_limit = self._icon_service.estimate_step( transaction) + 10000 # add some margin. return self._icon_service.send_transaction( SignedTransaction(transaction, owner, step_limit))
def test_transaction(self): self.logger.info('Start transfer transaction...') _user_wallet = self._wallet_array[1] _remote_wallet = self._wallet_array[2] _to = self._wallet_array[3] self._transfer_token(self._test1, _user_wallet, True) self._transfer_token(self._test1, _remote_wallet, True) self._transfer_token(self._test1, _to, True) #self._transfer_token(_remote_wallet, self._test1, False) response = self._call_balance(_user_wallet.get_address()) self.logger.info("BALANCE [%s] : %s" % (_user_wallet.get_address(), int(response, 16))) response = self._call_balance(_remote_wallet.get_address()) self.logger.info("BALANCE [%s] : %s" % (_remote_wallet.get_address(), int(response, 16))) response = self._call_balance(_to.get_address()) self.logger.info("BALANCE [%s] : %s" % (_to.get_address(), int(response, 16))) self.logger.info('Token Transfer Transaction Build ...') value = 100 params = { '_from': _user_wallet.get_address(), '_to': _to.get_address(), '_value': value } transaction = CallTransactionBuilder() \ .from_(_user_wallet.get_address()) \ .to(self._score_address) \ .step_limit(10_000_000) \ .nid(3) \ .nonce(100) \ .method("transfer") \ .params(params) \ .build() signedTransaction = SignedTransaction(transaction, _user_wallet) data = json.dumps(transaction.to_dict(), sort_keys=True, indent=4, separators=(',', ': ')) self.logger.debug(f'Inner TX Data : {data}') data = json.dumps(signedTransaction.signed_transaction_dict, sort_keys=True, indent=4, separators=(',', ': ')) self.logger.debug(f'Inner TX Signed Data : {data}') self.logger.info('Remote Excute Transaction Build ...') params = { '_data': f'{signedTransaction.signed_transaction_dict}'.encode() } transaction = CallTransactionBuilder() \ .from_(_remote_wallet.get_address()) \ .to(self._score_address) \ .step_limit(10_000_000) \ .nid(3) \ .nonce(100) \ .method("remotetx") \ .params(params) \ .build() signed_transaction = SignedTransaction(transaction, _remote_wallet) self.logger.info('Excute Transaction ...') tx_result = self.process_transaction(signed_transaction, self.icon_service) self.logger.debug('TX RESULT : %s' % tx_result) response = self._call_balance(_user_wallet.get_address()) self.logger.info("BALANCE [%s] : %s" % (_user_wallet.get_address(), int(response, 16))) response = self._call_balance(_remote_wallet.get_address()) self.logger.info("BALANCE [%s] : %s" % (_remote_wallet.get_address(), int(response, 16))) response = self._call_balance(_to.get_address()) self.logger.info("BALANCE [%s] : %s" % (_to.get_address(), int(response, 16)))