Transaction task submission method and device and terminal equipment

By setting out expiration detection contracts and building target transaction tasks in the blockchain system, the problem of slow transaction confirmation efficiency and confirmation speed in the blockchain system is solved, and the technical effect of quickly confirming transaction status and improving transaction confirmation efficiency is achieved.

CN119579313AActive Publication Date: 2025-03-07HANGZHOU HIGH-TECH ZONE (BINJIANG) INSTITUTE OF BLOCKCHAIN & DATA SECURITY
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411667258.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-20
Publication Date
2025-03-07
Estimated Expiration
2044-11-20

AI Technical Summary

Technical Problem

The transaction confirmation efficiency and confirmation speed in the blockchain system are slow, resulting in slow transaction confirmation or even unrecognition when users are busy on the Internet.

Method used

By setting up an expiration detection contract, the target transaction task is constructed based on the contract and the user's trading task. The target transaction task calls the expiration detection method in the expiration detection contract when it is executed, determines whether the user's trading task has expired, and querys the transaction receipt to confirm the transaction status.

Benefits of technology

Quickly determine whether the user's transaction task has expired, avoiding the user setting timeout time and constantly training the transaction receipts requested by blockchain nodes, significantly improving the transaction confirmation efficiency and confirmation speed, and saving users' time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119579313A_ABST
    Figure CN119579313A_ABST
Patent Text Reader

Abstract

The invention relates to a transaction task submission method and apparatus, and a terminal device. The method comprises the steps of obtaining a user transaction task and an expiration detection contract corresponding to the user transaction task; based on the expiration detection contract and the user transaction task, constructing a target transaction task, and when the target transaction task is executed, calling an expiration detection method in the expiration detection contract to detect whether the user transaction task is expired; sending the target transaction task to an execution node corresponding to the user transaction task; querying whether the execution node has generated a transaction receipt within a preset time period, and querying transaction state information in the transaction receipt when the execution node has generated the transaction receipt within the preset time period; and when the execution node has generated a transaction receipt within a preset time period and the transaction state information indicates that the transaction succeeds, determining that the user transaction task has been confirmed. Through application of the method and the device, the problems of relatively low transaction confirmation efficiency and confirmation speed in the block chain in related technologies are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of blockchain technology, and in particular, relates to a transaction task submission method, apparatus and terminal device. Background Art

[0002] In the blockchain system, for the sake of system performance and throughput, transactions submitted by users are often processed asynchronously, that is, after a transaction is submitted to a blockchain node, it first enters the transaction pool, is then packaged into blocks by a block-producing node, and is confirmed after consensus. In these processes, there may be certain factors that cause the transaction not to be packaged in the end, such as too low a transaction priority fee, the transaction has not been packaged and is deleted from the transaction pool, and a block reorganization occurs, which makes the packaged block invalid.

[0003] For users of blockchain, when the network is busy, transactions are often confirmed slowly or even unconfirmed. In this case, if the user chooses to retry the transaction, he or she needs to wait until the original transaction is really not confirmed, increase the transaction priority fee, and then initiate a new transaction, which often takes a lot of time (it is necessary to ensure that the previous transaction is really not confirmed, otherwise there may be an abnormal situation where both the previous transaction and the retried transaction are confirmed).

[0004] Currently, no effective solution has been proposed for the problems of slow transaction confirmation efficiency and speed in blockchain in related technologies. Summary of the invention

[0005] The embodiments of the present application provide a transaction task submission method, apparatus, and terminal device to at least solve the problem of slow transaction confirmation efficiency and confirmation speed in blockchain in the related art.

[0006] In a first aspect, an embodiment of the present application provides a transaction task submission method, including: obtaining a user transaction task and an expiration detection contract corresponding to the user transaction task; wherein an expiration detection method is set in the expiration detection contract; constructing a target transaction task based on the expiration detection contract and the user transaction task, wherein the target transaction task calls the expiration detection method in the expiration detection contract when being executed to detect whether the user transaction task has expired; sending the target transaction task to an execution node corresponding to the user transaction task; querying whether the execution node has generated a transaction receipt within a preset time period, and when the execution node has generated a transaction receipt within the preset time period, querying the transaction status information in the transaction receipt; when the execution node has generated a transaction receipt within the preset time period and the transaction status information in the transaction receipt indicates that the transaction is successful, determining that the user transaction task has been confirmed.

[0007] In some embodiments, a priority fee payment method is also provided in the expiration detection contract, wherein the priority fee payment method in the expiration detection contract is called when the target transaction task is executed to pay the priority fee for the user transaction task.

[0008] In some embodiments, a contract calling method is also provided in the expiration detection contract; based on the expiration detection contract and the user transaction task, constructing the target transaction task includes: determining whether the blockchain corresponding to the user transaction task supports calling multiple smart contracts for the same transaction; if the blockchain does not support calling multiple smart contracts for the same transaction, integrating the expiration detection method and the priority fee payment method in the expiration detection contract into the contract calling method, and calling the contract calling method to perform a cross-contract call on the smart contract corresponding to the user transaction task to obtain the target transaction task; if the blockchain supports calling multiple smart contracts for the same transaction, adding the expiration detection method in the expiration detection contract to the head part of the contract calling array corresponding to the user transaction task, and adding the priority fee payment method in the expiration detection contract to the tail part of the contract calling array to obtain the target transaction task.

[0009] In some embodiments, calling the priority fee payment method in the expiration detection contract to pay the priority fee for the user transaction task includes: calling the priority fee payment method in the expiration detection contract, obtaining the priority fee amount and the priority fee payment address corresponding to the user transaction task, and paying the priority fee for the user transaction task based on the priority fee amount and the priority fee payment address.

[0010] In some embodiments, calling an expiration detection method in an expiration detection contract to detect whether a user transaction task has expired includes: obtaining a transaction expiration time corresponding to the user transaction task, a block generation time of the blockchain corresponding to the user transaction task, and the first latest block number of the blockchain; based on the transaction expiration time, the block generation time, and the first latest block number, calculating the expired block number corresponding to the user transaction task; calling an expiration detection method in an expiration detection contract to obtain the current block number of the blockchain, and detecting the size relationship between the current block number and the expired block number; if the current block number is greater than the expired block number, determining that the user transaction task has expired; if the current block number is less than the expired block number, determining that the user transaction task has not expired.

[0011] In some embodiments, after querying whether the execution node has generated a transaction receipt within a preset time period, the method also includes: when the execution node has not generated a transaction receipt within the preset time period, querying the second latest block number of the blockchain corresponding to the user transaction task; when the second latest block number is greater than the current block number, determining that the user transaction task has expired; when the user transaction task has expired, adding a preset amount to the priority fee amount corresponding to the user transaction task to obtain an adjusted priority fee amount, and adding the adjusted priority fee amount to the priority fee payment method in the expiration detection contract, and then to the adjusted priority fee payment method; based on the expiration detection contract including the adjusted priority fee payment method and the user transaction task, constructing an adjusted target transaction task.

[0012] In some embodiments, when a user transaction task has expired, a preset amount is added to the priority fee amount corresponding to the user transaction task to obtain an adjusted priority fee amount, and the adjusted priority fee amount is added to the priority fee payment method in the expiration detection contract, and the adjusted priority fee payment method includes: when the user transaction task has expired, querying whether the number of transaction retries corresponding to the user transaction task exceeds the preset maximum number of retries; when the number of transaction retries exceeds the maximum number of retries, determining that the user transaction task has failed; when the number of transaction retries does not exceed the maximum number of retries, adding a preset amount to the priority fee amount corresponding to the user transaction task to obtain an adjusted priority fee amount; and increasing the number of transaction retries by one; and adding the adjusted priority fee amount to the priority fee payment method in the expiration detection contract, and obtaining the adjusted priority fee payment method.

[0013] In a second aspect, an embodiment of the present application provides a transaction task submission device, including: an acquisition module, used to acquire a user transaction task, and an expiration detection contract corresponding to the user transaction task; wherein an expiration detection method is provided in the expiration detection contract; a construction module, used to construct a target transaction task based on the expiration detection contract and the user transaction task, wherein the target transaction task calls the expiration detection method in the expiration detection contract when being executed to detect whether the user transaction task has expired; a sending module, used to send the target transaction task to an execution node corresponding to the user transaction task; a query module, used to query whether the execution node has generated a transaction receipt within a preset time period, and when the execution node has generated a transaction receipt within the preset time period, query the transaction status information in the transaction receipt; a confirmation module, used to determine that the user transaction task has been confirmed when the execution node has generated a transaction receipt within the preset time period and the transaction status information in the transaction receipt indicates that the transaction is successful.

[0014] In a third aspect, an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the transaction task submission method of any one of the above-mentioned first aspects is implemented.

[0015] In a fourth aspect, an embodiment of the present application provides a computer program product, including a computer program, and when the computer program is run, the transaction task submission method described in any one of the above-mentioned first aspects is executed.

[0016] Compared with the related art, the transaction task submission method, device and terminal device provided in the embodiment of the present application, by setting an expiration detection contract, constructs a new transaction task (i.e., target transaction task) based on the expiration detection contract and the user transaction task, and then sends the target transaction task to the execution node in the blockchain. When the target transaction task is executed by the execution node, the expiration detection method in the expiration detection contract can be called to determine whether the user transaction task has expired. When the user transaction task has not expired, it can be queried whether the execution node has generated a transaction receipt within a preset time period, and when the execution node has generated a transaction receipt within a preset time period and the transaction status information in the transaction receipt is a successful transaction, it is determined that the user transaction task has been confirmed. By calling the expiration detection contract, it is possible to quickly determine whether the user transaction task has expired, and it is not constrained by the blockchain's own transaction mechanism. The user does not need to set a timeout after initiating the transaction, and continuously train the transaction receipt of the execution node requesting the blockchain, which greatly improves the transaction confirmation efficiency and confirmation speed in the blockchain, and at the same time, saves a lot of user time. Through this application, the problems of slow transaction confirmation efficiency and confirmation speed in blockchain in related technologies are solved, and the technical effect of improving transaction confirmation efficiency and confirmation speed in blockchain is achieved.

[0017] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0019] Figure 1 is a flow chart of a transaction task submission method according to an embodiment of the present application;

[0020] Figure 2is a flow chart of a transaction task submission method according to another embodiment of the present application;

[0021] Figure 3 It is a structural schematic diagram of a transaction task submission device according to an embodiment of the present application;

[0022] Figure 4 It is a structural diagram of a terminal device according to an embodiment of the present application. DETAILED DESCRIPTION

[0023] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0024] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0025] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0026] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.

[0027] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0028] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0029] In the blockchain system, for the sake of system performance and throughput, transactions submitted by users are often processed asynchronously, that is, after a transaction is submitted to a blockchain node, it first enters the transaction pool, is then packaged into blocks by a block-producing node, and is confirmed after consensus. In these processes, there may be certain factors that cause the transaction not to be packaged in the end, such as too low a transaction priority fee, the transaction has not been packaged and is deleted from the transaction pool, and a block reorganization occurs, which makes the packaged block invalid.

[0030] For users of blockchain, when the network is busy, transactions are often confirmed slowly or even unconfirmed. In this case, if the user chooses to retry the transaction, he or she needs to wait until the original transaction is really not confirmed, increase the transaction priority fee, and then initiate a new transaction, which often takes a lot of time (it is necessary to ensure that the previous transaction is really not confirmed, otherwise there may be an abnormal situation where both the previous transaction and the retried transaction are confirmed).

[0031] At present, users often need to set a timeout period to confirm the initiated transactions, and continuously request the transaction receipt from the blockchain node during the timeout period. If the transaction receipt is received during the request, it is determined that the transaction has been confirmed; if the transaction receipt is not received during the timeout period, it is determined that the transaction has not been confirmed. The timeout period is often very long, which will consume a lot of user time.

[0032] Currently, no effective solution has been proposed for the problems of slow transaction confirmation efficiency and speed in blockchain in related technologies.

[0033] In view of this, the embodiment of the present application provides a transaction task submission method, by setting an expiration detection contract, building a new transaction task (i.e., target transaction task) based on the expiration detection contract and the user transaction task, and then sending the target transaction task to the execution node in the blockchain, the target transaction task can be executed by the execution node. The expiration detection method in the expiration detection contract can be called to determine whether the user transaction task has expired. When the user transaction task has not expired, it can be queried whether the execution node has generated a transaction receipt within a preset time period, and when the execution node has generated a transaction receipt within a preset time period and the transaction status information in the transaction receipt is a successful transaction, it is determined that the user transaction task has been confirmed. By calling the expiration detection contract, it is possible to quickly determine whether the user transaction task has expired, and it is not constrained by the blockchain's own transaction mechanism. The user does not need to set a timeout after initiating the transaction, and continuously train the transaction receipt of the execution node requesting the blockchain, which greatly improves the transaction confirmation efficiency and confirmation speed in the blockchain, and at the same time, saves a lot of time for the user. Through this application, the problem of slow transaction confirmation efficiency and confirmation speed in the blockchain in the related technology is solved, and the technical effect of improving the transaction confirmation efficiency and confirmation speed in the blockchain is achieved.

[0034] The following will be combined Figure 1 For an explanation of the transaction task submission method provided by an embodiment of the present application, please refer to Figure 1 , Figure 1 is a flow chart of a transaction task submission method according to an embodiment of the present application. Figure 1 As shown, the method includes:

[0035] Step S101, obtaining a user transaction task and an expiration detection contract corresponding to the user transaction task; wherein an expiration detection method is provided in the expiration detection contract.

[0036] In this embodiment, the user transaction task can be a constructed transaction body (including the to address and callData data), wherein the to address represents the address of the contract to be called by the user transaction task, and the callData data represents the encoded parameter data of the contract to be called by the user transaction task.

[0037] Step S102, constructing a target transaction task based on the expiration detection contract and the user transaction task, wherein the target transaction task calls the expiration detection method in the expiration detection contract when being executed to detect whether the user transaction task has expired.

[0038] In this embodiment, the expiration detection contract can be a smart contract, which needs to implement certain interface logic (not limited to the implementation language and blockchain platform, only the corresponding logic needs to be implemented) to check whether the user's transaction task is expired.

[0039] Specifically, the expiration detection contract can be used to package the original transaction call in the user transaction task to generate the target transaction task. When the target transaction task is executed by the execution node (e.g., the block node) of the blockchain, the expiration detection method in the expiration detection contract can be called to detect whether the user transaction task has expired. If the user transaction task has expired, an error message can be returned; if the user transaction task has not expired, the execution node can be waited for to package the user transaction task in the target transaction task.

[0040] Combine the following Figure 2 The specific content of step S102 is described and illustrated. Figure 2 is a flow chart of a transaction task submission method according to another embodiment of the present application. Figure 2 As shown, in one embodiment, step S102 includes the following steps:

[0041] Step S201, determine whether the blockchain corresponding to the user's transaction task supports calling multiple smart contracts for the same transaction. If yes, proceed to step S202; if no, proceed to step S203.

[0042] Step S202, add the expiration detection method in the expiration detection contract to the head part of the contract call array corresponding to the user transaction task, and add the priority fee payment method in the expiration detection contract to the tail part of the contract call array to obtain the target transaction task.

[0043] Step S203, integrate the expiration detection method and the priority fee payment method in the expiration detection contract into the contract calling method, and call the contract calling method to perform a cross-contract call on the smart contract corresponding to the user's transaction task to obtain the target transaction task.

[0044] In this embodiment, the expiration detection contract may include not only the expiration detection method, but also the contract calling method and the priority fee payment method. When the target transaction task is completed, the priority fee payment method in the expiration detection contract is called to pay the priority fee for the user transaction task.

[0045] In this embodiment, the contract format of the expiration detection contract can have two types, corresponding to blockchains that support calling multiple smart contracts for the same transaction (for example, Solana, Aptos, Sui and other blockchains), and blockchains that do not support calling multiple smart contracts for the same transaction (for example, EVM-type blockchains).

[0046] Specifically, the contract format of the expiration detection contract of the blockchain that supports calling multiple smart contracts for the same transaction can be as follows:

[0047] func checkExpired(expiredBlockNumber int256)

[0048] func payTip(tipReceiver address, tipAmount int256)

[0049] Among them, "func" represents a function or method, and "checkExpired()" represents the expiration detection method in the expiration detection contract. "expiredBlockNumber" represents the preset expired block number. The expiration detection method determines whether the user's transaction task has expired by reading the current block number of the blockchain corresponding to the user's transaction task and comparing it with the preset expired block number.

[0050] “payTip()” indicates the priority fee payment method in the expiration detection contract. “tipReceiver address” indicates the priority fee payment address (a zero address indicates that the priority fee is paid to the coinbase address of the block node). “tipAmount” indicates the preset priority fee amount.

[0051] In one embodiment, calling the expiration detection method in the expiration detection contract to detect whether the user transaction task has expired includes the following steps:

[0052] Step 1, obtain the transaction expiration time corresponding to the user transaction task, the block generation time of the blockchain corresponding to the user transaction task, and the first latest block number of the blockchain.

[0053] Step 2: Based on the transaction expiration time, block generation time and the first latest block number, calculate the expired block number corresponding to the user's transaction task.

[0054] Step 3, call the expiration detection method in the expiration detection contract, obtain the current block number of the blockchain, and detect the size relationship between the current block number and the expired block number. If the current block number is greater than the expired block number, it is determined that the user's transaction task has expired; if the current block number is less than the expired block number, it is determined that the user's transaction task has not expired.

[0055] In this embodiment, the transaction expiration time can be set by the user, and the expiration detection contract can implement a custom expiration time for the transaction. For example, the user can set the transaction expiration time to 30 seconds. Assuming that the blockchain corresponding to the user's transaction task is Ethereum, and the block time of Ethereum is 12 seconds per block, then the first latest block number of the blockchain plus 30 / 12≈3 is the expired block number corresponding to the user's transaction task.

[0056] In one embodiment, multiple instances may query the latest block number of the blockchain. Since the block broadcast is implemented through p2p, the p2p nodes connected to some instances may have lags at the same time, and different results may be queried separately (for example, assuming there are 5 instances, and the latest block numbers of the blockchain queried are 10, 10, 11, 11, 10 respectively). At this time, outliers (too large values, too small values) can be removed (for example, remove the excessive value 11), and the first latest block number of the blockchain (for example, 10) can be obtained after average calculation.

[0057] In one embodiment, calling the priority fee payment method in the expiration detection contract to pay the priority fee for the user transaction task includes: calling the priority fee payment method in the expiration detection contract, obtaining the priority fee amount and the priority fee payment address corresponding to the user transaction task, and paying the priority fee for the user transaction task based on the priority fee amount and the priority fee payment address.

[0058] Specifically, the priority fee payment method can be called after the user transaction task is executed (block generation is successful). First, it can be detected whether the priority fee payment address is zero. If the priority fee payment address (tipReceiver address) is zero, then the priority fee amount (tipAmount) is transferred to the coinbase address, for example, tipAmount native Tokens are transferred to the coinbase address; if the priority fee payment address is not zero, then the priority fee amount (tipAmount) is transferred to the priority fee payment address, for example, tipAmount native Tokens are transferred to the tipReceiver address.

[0059] The contract format of the expiration detection contract for a blockchain that does not support calling multiple smart contracts in the same transaction can be as follows:

[0060] func execute(to address, callData[]byte, expiredBlockNumber int256, tipReceiver address, tipAmount int256)

[0061] Among them, "func" represents a function or method, "execute()" represents the contract calling method in the expiration detection contract. It should be noted that this contract calling method integrates the expiration detection method and the priority fee payment method. "to address" represents the address of the contract to be called by the user's transaction task, and "callData[]byte" represents the encoded parameter data of the contract to be called by the user's transaction task.

[0062] The implementation logic of the expiration detection contract for blockchains that do not support calling multiple smart contracts in the same transaction includes:

[0063] 1. Expiration detection method: Get the current block number of the blockchain, and detect the size relationship between the current block number and expiredBlockNumber. If the current block number is greater than expiredBlockNumber, it is determined that the user's transaction task has expired and an error message is returned; if the current block number is less than expiredBlockNumber, it is determined that the user's transaction task has not expired.

[0064] 2. Contract calling method: If the first step detects that the user transaction task has not expired, use to address and callData[]byte to make a cross-contract call to the smart contract corresponding to the user transaction task.

[0065] 3. Priority fee payment method: If the second step is successfully called (that is, the user transaction task in the target transaction task is successfully executed), the priority fee payment is made: if the tipReceiver address is zero, then transfer tipAmount native tokens to the coinbase address; if the tipReceiver address is not zero, then transfer tipAmount native tokens to the tipReceiver address.

[0066] It should be noted that for blockchains that do not support calling multiple smart contracts for the same transaction, the expiration detection contract must include the above-mentioned expiration detection method, contract calling method and priority fee payment method; however, for blockchains that support calling multiple smart contracts for the same transaction, the expiration detection contract can only include the above-mentioned expiration detection method and priority fee payment method. By adding the expiration detection method and the priority fee payment method to the head and tail parts of the contract call array corresponding to the user transaction task, the expiration detection method, user transaction task and priority fee payment method can be executed in the order of the contract call array.

[0067] Step S103: sending the target transaction task to the execution node corresponding to the user transaction task.

[0068] In this embodiment, the callback function of the signature transaction passed in by the user can be obtained, and the callback function can be used to sign the target transaction task to obtain the hash value of the target transaction task. Then, multiple instances can be used to send the target transaction task to different execution nodes (for example, the execution node can be an RPC (Remote Procedure Call) node such as a block node), thereby preventing a single connected node from failing due to a single point of failure due to network reasons or other reasons.

[0069] Step S104, querying whether the execution node has generated a transaction receipt within a preset time period, and if the execution node has generated a transaction receipt within the preset time period, querying the transaction status information in the transaction receipt.

[0070] Step S105: When the execution node has generated a transaction receipt within a preset time period and the transaction status information in the transaction receipt indicates that the transaction is successful, it is determined that the user transaction task has been confirmed.

[0071] In this embodiment, a timer can be used to set a preset time period, and the preset time period can be set to min (1 second, the block time of the blockchain / 4), so as to determine as soon as possible whether the user transaction task has been confirmed.

[0072] Specifically, after the timer is turned on, a timer signal can be sent after a preset time period (for example, 1 second) has passed. After receiving the timer signal, the SDK instance supporting the blockchain can be used in parallel to query whether the execution node has generated a transaction receipt based on the hash value of the target transaction task. If any instance queries the transaction receipt, the transaction status information in the transaction receipt can be queried. Specifically, the transaction success field in the transaction receipt can be queried. If the transaction success field is yes, it can be determined that the user's transaction task has been confirmed, the waiting is interrupted, and the transaction receipt is directly returned. If no instance queries the transaction receipt, it can be determined that the user's transaction task has expired.

[0073] like Figure 2 As shown, in one embodiment, after step S105, the method further includes:

[0074] Step S204, query whether the second latest block number of the blockchain corresponding to the user transaction task is greater than the current block number. If so, proceed to step S205.

[0075] In this embodiment, when the execution node does not generate a transaction receipt within a preset time period, the second latest block number of the blockchain corresponding to the user's transaction task can be queried, and the size relationship between the second latest block number and the current block number can be determined. It should be noted that the current block number of the blockchain refers to the block number of the blockchain read when the expiration detection method of the expiration detection contract is called, and the second latest block number of the blockchain refers to the latest block number of the blockchain queried when the execution node does not generate a transaction receipt within the preset time period.

[0076] Step S205, determining that the user transaction task has expired.

[0077] In this embodiment, when the second latest block number is greater than the current block number, it can be determined that the user transaction task has expired.

[0078] Step S206, add a preset amount to the priority fee amount corresponding to the user transaction task to obtain an adjusted priority fee amount, and add the adjusted priority fee amount to the priority fee payment method in the expiration detection contract.

[0079] In this embodiment, when the user transaction task has expired, the priority fee increase operation can be performed to increase the confirmation probability of subsequent retry transactions.

[0080] In one embodiment, a preset amount is added to the priority fee amount corresponding to the user transaction task to obtain an adjusted priority fee amount, and the adjusted priority fee amount is added to the priority fee payment method in the expiration detection contract. The adjusted priority fee payment method includes the following steps:

[0081] Step 1: If the user transaction task has expired, check whether the transaction retry times corresponding to the user transaction task exceeds the preset maximum retry times. If yes, proceed to step 2; if no, proceed to step 3.

[0082] Step 2: When the transaction retry times exceed the maximum retry times, it is determined that the user transaction task has failed.

[0083] Step 3, when the number of transaction retries does not exceed the maximum number of retries, add the preset amount to the priority fee amount corresponding to the user's transaction task to obtain the adjusted priority fee amount; increase the number of transaction retries by one; and add the adjusted priority fee amount to the priority fee payment method in the expiration detection contract, and then get the adjusted priority fee payment method.

[0084] In this embodiment, the maximum number of retries set by the user and the floating amount of the priority fee for each retry (i.e., the preset amount) can be obtained. As long as the transaction retry number corresponding to the user's transaction task does not exceed the maximum number of retries, the transaction retry can be performed for the user's transaction task.

[0085] Step S207, constructing an adjusted target transaction task based on the expiration detection contract including the adjusted priority fee payment method and the user transaction task.

[0086] In this embodiment, after obtaining the adjusted target transaction task, the adjusted target transaction task can be returned to step S103, that is, the adjusted target transaction task can be sent to the execution node corresponding to the user transaction task, and the transaction can continue to be attempted on the chain. After increasing the priority fee amount, the probability of the adjusted target transaction task being confirmed can also be increased, thereby reducing the delay from transaction sending to transaction confirmation.

[0087] In one embodiment, the above steps can be encapsulated into a software development kit (SDK), for example, it can be named TxSubmitSDK, which can assist in transforming user transaction tasks to support expiration detection contracts without user awareness, and support customized fast transaction retry. The steps of calling the expiration detection contract, confirming the transaction, checking the retry logic, etc. can be encapsulated into TxSubmitSDK, and the steps in the above-mentioned transaction task submission method embodiments can be performed using TxSubmitSDK.

[0088] In this way, through the SDK that matches the transaction task submission method provided in the embodiment of the present application, non-intrusive transaction rapid retry can be achieved, and automatic increment of priority fees can be supported to increase the probability of transactions being packaged, greatly improve the probability of transactions being confirmed on the chain, and reduce the delay from the transaction being sent to the transaction being confirmed.

[0089] Through the above steps S101 to S207, by setting an expiration detection contract, a new transaction task (i.e., a target transaction task) is constructed based on the expiration detection contract and the user transaction task, and then the target transaction task is sent to the execution node in the blockchain. When the target transaction task is executed by the execution node, the expiration detection method in the expiration detection contract can be called to determine whether the user transaction task has expired. When the user transaction task has not expired, it can be queried whether the execution node has generated a transaction receipt within a preset time period. When the execution node has generated a transaction receipt within the preset time period and the transaction status information in the transaction receipt indicates that the transaction is successful, it is determined that the user transaction task has been confirmed. By calling the expiration detection contract, it is possible to quickly determine whether the user's transaction task has expired, and it is not constrained by the blockchain's own transaction mechanism. The user does not need to set a timeout after initiating the transaction, and continuously request the transaction receipt of the blockchain's execution node in rotation. This greatly improves the transaction confirmation efficiency and confirmation speed in the blockchain, and at the same time, saves a lot of user time; at the same time, when it is confirmed that the user's transaction task has expired, the priority fee amount of the user's transaction task can be increased for retry, thereby increasing the probability of the adjusted target transaction task being confirmed, thereby reducing the delay from transaction sending to transaction confirmation. Through this application, the problem of slow transaction confirmation efficiency and confirmation speed in the blockchain in the related technology is solved, and the technical effect of improving the transaction confirmation efficiency and confirmation speed in the blockchain is achieved.

[0090] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0091] Corresponding to the transaction task submission method described in the above embodiment, Figure 3 A schematic diagram of the structure of a transaction task submission device according to an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.

[0092] See also Figure 3 The transaction task submission device 3 includes: an acquisition module 30, which is used to acquire the user transaction task and the expiration detection contract corresponding to the user transaction task; wherein the expiration detection contract is provided with an expiration detection method; a construction module 31, which is used to construct a target transaction task based on the expiration detection contract and the user transaction task, wherein the target transaction task calls the expiration detection method in the expiration detection contract when being executed to detect whether the user transaction task has expired; a sending module 32, which is used to send the target transaction task to the execution node corresponding to the user transaction task; a query module 33, which is used to query whether the execution node has generated a transaction receipt within a preset time period, and when the execution node has generated a transaction receipt within the preset time period, query the transaction status information in the transaction receipt; a confirmation module 34, which is used to determine that the user transaction task has been confirmed when the execution node has generated a transaction receipt within the preset time period and the transaction status information in the transaction receipt indicates that the transaction is successful.

[0093] In one embodiment, a priority fee payment method is also provided in the expiration detection contract, wherein the priority fee payment method in the expiration detection contract is called when the target transaction task is executed to pay the priority fee for the user transaction task.

[0094] In one embodiment, a contract calling method is also provided in the expiration detection contract; the construction module 31 is also used to determine whether the blockchain corresponding to the user transaction task supports calling multiple smart contracts for the same transaction; if the blockchain does not support calling multiple smart contracts for the same transaction, the expiration detection method and the priority fee payment method in the expiration detection contract are integrated into the contract calling method, and the contract calling method is called to perform a cross-contract call on the smart contract corresponding to the user transaction task to obtain the target transaction task; if the blockchain supports calling multiple smart contracts for the same transaction, the expiration detection method in the expiration detection contract is added to the head part of the contract calling array corresponding to the user transaction task, and the priority fee payment method in the expiration detection contract is added to the tail part of the contract calling array to obtain the target transaction task.

[0095] In one embodiment, calling the priority fee payment method in the expiration detection contract to pay the priority fee for the user transaction task includes: calling the priority fee payment method in the expiration detection contract, obtaining the priority fee amount and the priority fee payment address corresponding to the user transaction task, and paying the priority fee for the user transaction task based on the priority fee amount and the priority fee payment address.

[0096] In one embodiment, calling the expiration detection method in the expiration detection contract to detect whether the user transaction task has expired includes: obtaining the transaction expiration time corresponding to the user transaction task, the block generation time of the blockchain corresponding to the user transaction task, and the first latest block number of the blockchain; based on the transaction expiration time, the block generation time and the first latest block number, calculating the expired block number corresponding to the user transaction task; calling the expiration detection method in the expiration detection contract, obtaining the current block number of the blockchain, and detecting the size relationship between the current block number and the expired block number, if the current block number is greater than the expired block number, it is determined that the user transaction task has expired; if the current block number is less than the expired block number, it is determined that the user transaction task has not expired.

[0097] In one embodiment, the confirmation module 34 is also used to query the second latest block number of the blockchain corresponding to the user transaction task when the execution node does not generate a transaction receipt within a preset time period; when the second latest block number is greater than the current block number, determine that the user transaction task has expired; when the user transaction task has expired, add a preset amount to the priority fee amount corresponding to the user transaction task to obtain an adjusted priority fee amount, and add the adjusted priority fee amount to the priority fee payment method in the expiration detection contract, and then to the adjusted priority fee payment method; based on the expiration detection contract including the adjusted priority fee payment method and the user transaction task, construct an adjusted target transaction task.

[0098] In one embodiment, the confirmation module 34 is also used to query whether the number of transaction retries corresponding to the user transaction task exceeds the preset maximum number of retries when the user transaction task has expired; if the number of transaction retries exceeds the maximum number of retries, determine that the user transaction task has failed; if the number of transaction retries does not exceed the maximum number of retries, add the preset amount to the priority fee amount corresponding to the user transaction task to obtain an adjusted priority fee amount; and increase the number of transaction retries by one; and add the adjusted priority fee amount to the priority fee payment method in the expiration detection contract, and then obtain the adjusted priority fee payment method.

[0099] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0100] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0101] Figure 4 is a schematic diagram of the structure of a terminal device according to an embodiment of the present application. Figure 4 As shown, the terminal device 4 includes: at least one processor 40 ( Figure 4 Only one is shown in the figure) a processor, a memory 41, and a computer program 42 stored in the memory 41 and executable on at least one processor 40. When the processor 40 executes the computer program 42, the steps in any of the above-mentioned transaction task submission method embodiments are implemented.

[0102] The terminal device 4 may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The terminal device 4 may include but is not limited to a processor 40 and a memory 41. It is understood by those skilled in the art that Figure 4 It is only an example of the terminal device 4 and does not constitute a limitation on the terminal device 4. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, it may also include input and output devices, network access devices, etc.

[0103] The processor 40 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0104] In some embodiments, the memory 41 may be an internal storage unit of the terminal device 4, such as a hard disk or memory of the terminal device 4. In other embodiments, the memory 41 may also be an external storage device of the terminal device 4, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device 4. In other embodiments, the memory 41 may also include both an internal storage unit and an external storage device of the terminal device 4. The memory 41 is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as program codes of a computer program 42. The memory 41 may also be used to temporarily store data that has been output or is to be output.

[0105] The embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned transaction task submission method embodiments can be implemented.

[0106] An embodiment of the present application provides a computer program product. When the computer program product runs on a mobile terminal, the mobile terminal can implement the steps in the above-mentioned transaction task submission method embodiments when executing the computer program product.

[0107] The present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of each of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera device / terminal device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a disk or an optical disk.

[0108] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0109] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0110] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0111] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0112] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A transaction task submission method, characterized in that: include: Obtaining a user transaction task and an expiration detection contract corresponding to the user transaction task; wherein the expiration detection contract is provided with an expiration detection method; Based on the expiration detection contract and the user transaction task, a target transaction task is constructed, wherein the target transaction task calls the expiration detection method in the expiration detection contract when being executed to detect whether the user transaction task has expired; Sending the target transaction task to an execution node corresponding to the user transaction task; querying whether the execution node has generated a transaction receipt within a preset time period, and if the execution node has generated the transaction receipt within the preset time period, querying the transaction status information in the transaction receipt; When the execution node has generated the transaction receipt within the preset time period, and the transaction status information in the transaction receipt indicates that the transaction is successful, it is determined that the user transaction task has been confirmed.

2. The method according to claim 1, characterized in that: The expiration detection contract is also provided with a priority fee payment method, wherein the priority fee payment method in the expiration detection contract is called when the target transaction task is executed to pay the priority fee for the user transaction task.

3. The method according to claim 2, characterized in that The expiration detection contract also has a contract calling method; Based on the expiration detection contract and the user transaction task, constructing the target transaction task includes: Determine whether the blockchain corresponding to the user transaction task supports calling multiple smart contracts for the same transaction; In the case where the blockchain does not support calling multiple smart contracts for the same transaction, the expiration detection method and the priority fee payment method in the expiration detection contract are integrated into the contract calling method, and the contract calling method is called to perform a cross-contract call on the smart contract corresponding to the user transaction task to obtain the target transaction task; In the case where the blockchain supports calling multiple smart contracts for the same transaction, the expiration detection method in the expiration detection contract is added to the head part of the contract call array corresponding to the user transaction task, and the priority fee payment method in the expiration detection contract is added to the tail part of the contract call array to obtain the target transaction task.

4. The method according to claim 2 or 3, characterized in that: Calling the priority fee payment method in the expiration detection contract to pay the priority fee for the user transaction task includes: The priority fee payment method in the expiration detection contract is called to obtain the priority fee amount and the priority fee payment address corresponding to the user transaction task, and based on the priority fee amount and the priority fee payment address, the priority fee is paid for the user transaction task.

5. The method according to claim 4, characterized in that Calling the expiration detection method in the expiration detection contract to detect whether the user transaction task has expired includes: Obtaining a transaction expiration time corresponding to the user transaction task, a block generation time of the blockchain corresponding to the user transaction task, and the first latest block number of the blockchain; Based on the transaction expiration time, the block generation time and the first latest block number, calculate and obtain the expired block number corresponding to the user transaction task; The expiration detection method in the expiration detection contract is called to obtain the current block number of the blockchain, and detect the size relationship between the current block number and the expired block number. If the current block number is greater than the expired block number, it is determined that the user transaction task has expired; if the current block number is less than the expired block number, it is determined that the user transaction task has not expired.

6. The method according to claim 5, characterized in that After querying whether the execution node has generated a transaction receipt within a preset time period, the method further includes: When the execution node fails to generate the transaction receipt within the preset time period, querying the second latest block number of the blockchain corresponding to the user transaction task; When the second latest block number is greater than the current block number, determining that the user transaction task has expired; In the case where the user transaction task has expired, adding a preset amount to the priority fee amount corresponding to the user transaction task to obtain an adjusted priority fee amount, and adding the adjusted priority fee amount to the priority fee payment method in the expiration detection contract to obtain the adjusted priority fee payment method; Based on the expiration detection contract including the adjusted priority fee payment method and the user transaction task, an adjusted target transaction task is constructed.

7. The method according to claim 6, characterized in that In the case where the user transaction task has expired, a preset amount is added to the priority fee amount corresponding to the user transaction task to obtain an adjusted priority fee amount, and the adjusted priority fee amount is added to the priority fee payment method in the expiration detection contract. The adjusted priority fee payment method includes: In the case where the user transaction task has expired, querying whether the transaction retry number corresponding to the user transaction task exceeds the preset maximum retry number; When the transaction retry times exceed the maximum retry times, determining that the user transaction task has failed; When the number of transaction retries does not exceed the maximum number of retries, a preset amount is added to the priority fee amount corresponding to the user transaction task to obtain an adjusted priority fee amount; the number of transaction retries is increased by one; and the adjusted priority fee amount is added to the priority fee payment method in the expiration detection contract to obtain the adjusted priority fee payment method.

8. A transaction task submission device, characterized in that: include: An acquisition module, used to acquire a user transaction task and an expiration detection contract corresponding to the user transaction task; wherein the expiration detection contract is provided with an expiration detection method; A construction module, configured to construct a target transaction task based on the expiration detection contract and the user transaction task, wherein the target transaction task calls an expiration detection method in the expiration detection contract when being executed to detect whether the user transaction task has expired; A sending module, used for sending the target transaction task to an execution node corresponding to the user transaction task; A query module, used to query whether the execution node has generated a transaction receipt within a preset time period, and if the execution node has generated the transaction receipt within the preset time period, query the transaction status information in the transaction receipt; The confirmation module is used to determine that the user transaction task has been confirmed when the execution node has generated the transaction receipt within the preset time period and the transaction status information in the transaction receipt indicates that the transaction is successful.

9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the transaction task submission method according to any one of claims 1 to 7 is implemented.

10. A computer program product, characterized in that It comprises a computer program, which, when executed, enables the transaction task submission method according to any one of claims 1 to 7 to be executed.

Citation Information

Patent Citations

  • Transaction execution method, computer equipment and storage medium

    CN112734574A

  • Method and system of transaction dispute resolution

    US20230281617A1

  • Blockchain-based supervision method for electronic immunity passport

    US20240348455A1

  • Blockchain transaction method, apparatus and device, and computer readable storage medium

    WO2021052098A1

  • Transaction execution method, computer device, and storage medium

    WO2022148320A1