A cross-contract asset transfer method, device and storage medium
By configuring and proof-keeping transactions in the blockchain system, asset transfer between dynamic contracts and static contracts is realized, the problem of contract assets not being able to flow freely in the same blockchain network is solved, and two-way free circulation of assets and strict transaction parameter verification is realized.
Patent Information
- Application Number
- CN202111456930.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-02
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2041-12-02
AI Technical Summary
In the field of blockchain technology, different types of contract assets of the same blockchain network cannot be freely circulated, and exchanges, etc. are usually required to be transferred as intermediaries, resulting in high asset transfer costs. Dynamic contracts are not applicable to all situations, and free circulation of cross-contract assets is required.
By configuring management contracts in the blockchain system, the administrator initiates the contract account address of the evidence storage asset transfer contract and the contract address of the assets that support cross-contract transfer, realizing asset transfer between dynamic contracts and static contracts. The specific method includes initiating asset lock transactions in a dynamic contract, transferring assets to the contract account address of the asset transfer contract, and performing coin transactions in the static contract to generate static contract assets of equal value.
It realizes the two-way free circulation of assets between dynamic contracts and static contracts in the same blockchain network, strictly verify the parameter settings of the order of transactions before and after, prevent cheating, ensure the order of asset transfers and unlocking, and avoid the situation of minting and locking assets.
Smart Images

Figure CN114511310B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer technology, and in particular, relates to a cross-contract asset transfer method, device and storage medium. Background Art
[0002] In the field of blockchain technology, smart contracts play a vital role. Smart contracts can be divided into dynamic contracts and static native contracts. Dynamic contracts maintain the status of their corresponding digital assets through virtual machines, while static native contracts maintain the status of digital assets based on the underlying deployed contracts themselves. At present, different types of contract assets based on the same blockchain network cannot circulate freely, and usually require exchanges as intermediaries for transfer, which will increase the cost of asset transfer. Dynamic contracts are not suitable for all situations. Sometimes, static native contracts need to be used due to factors such as performance. In this case, how to achieve the free flow of cross-contract assets is particularly important. Summary of the invention
[0003] In order to solve the above problems, the present invention provides a cross-contract asset transfer method, device and storage medium to achieve the two-way free flow of dynamic contract digital assets and static contract digital assets.
[0004] The present invention adopts the following technical solutions.
[0005] In a first aspect, a method for transferring assets across contracts is provided, the method being used to transfer assets from a dynamic contract to a static contract, the method being applicable to a blockchain system, a management contract being configured in the blockchain system, an administrator of the blockchain system initiating a deposit transaction to deposit a contract account address for an asset transfer contract and a plurality of contract addresses of assets supporting cross-contract transfer in the management contract; the method comprising: an initiator initiating an asset locking transaction in a first contract and configuring target asset information, the asset locking transaction being used to transfer a first quantity of first contract assets in the initiator's account address to a contract account address of the asset transfer contract and locking the first contract, the target asset information comprising the contract address of a second contract asset, the first contract being a dynamic contract;
[0006] The initiator initiates a minting transaction anchored to the asset locking transaction in the second contract, and packages the asset locking transaction and the minting transaction into an asset transfer transaction group and sends it to the blockchain system; the minting transaction is used to generate a second quantity of second contract assets in the second contract, the second quantity of second contract assets is equal to the first quantity of first contract assets, and the second contract is a static contract;
[0007] Executing the asset locking transaction;
[0008] The minting transaction is executed in the second contract, and the steps of the minting transaction include:
[0009] Parse the asset lock transaction to obtain first transaction information. The first transaction information includes the contract account address of the asset transfer contract, the first quantity, and the contract address of the second contract asset;
[0010] Calling the corresponding preset parameters in the management contract to verify the contract account address of the asset transfer contract and the contract address of the second contract asset in the first transaction information; the preset parameters are preset by the initiator based on the management contract before the transaction;
[0011] If the verification is passed, a minting operation is performed in the second contract to generate a second amount of second contract assets.
[0012] Preferably, the method also includes: the initiator issues a first transaction at the same time as the asset locking transaction and the coin minting transaction, and packages it together with the asset locking transaction and the coin minting transaction to add it to the asset transfer transaction group, the first transaction is used to transfer the generated second contract asset to the application transaction contract for asset trading; the application transaction contract is used for trading static contract assets.
[0013] In a second aspect, a cross-contract asset transfer method is provided, the method being used to flow assets back from a static contract to a dynamic contract, the method comprising: an initiator initiating an extraction transaction in a second contract and configuring a reflow address, the extraction transaction being used to transfer a third amount of second contract assets to a contract account address of the asset transfer contract;
[0014] The initiator initiates a destruction transaction based on the withdrawal transaction in the asset transfer contract, and the destruction transaction is used to destroy the second contract asset in the contract account address transferred into the asset transfer contract;
[0015] The initiator submits the extraction transaction and destruction transaction to the blockchain system administrator;
[0016] The blockchain system administrator parses the parameters in the extraction transaction and the destruction transaction and generates an unlocking transaction, and submits the extraction transaction, the destruction transaction and the unlocking transaction into an asset unlocking transaction group to the blockchain system;
[0017] Based on the execution of the asset unlocking transaction group, a fourth quantity of the first contract assets in the contract account address of the asset transfer contract is unlocked and transferred to the return address.
[0018] In a third aspect, a computer device is provided, comprising one or more processors;
[0019] a memory for storing one or more programs,
[0020] When the one or more programs are executed by the one or more processors, the one or more processors are caused to perform the methods according to the first and second aspects described above.
[0021] According to a fourth aspect, a storage medium storing a computer program is provided, and when the program is executed by a processor, the method described in the first and second aspects above is implemented.
[0022] The beneficial effect of the present invention is that it first realizes the asset transfer between heterogeneous contracts in the same blockchain network, that is, the asset transfer between dynamic contracts and static native contracts. At the same time, it strictly verifies the parameter settings of the previous and subsequent transactions to ensure that the coin minting operation is based on the previous asset locking transaction, and ensures that coin minting will not be performed out of thin air to cause cheating. Submitting transactions in the form of transaction groups can ensure that transactions in the transfer process are executed in the required order, and locked assets can be unlocked when the assets flow back, and there will be no situation where contract assets are minted while being locked. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 This is a schematic diagram of a process in Example 1 of the present invention;
[0024] Figure 2 This is a schematic diagram of the structure of a computer device according to Embodiment 2 of the present invention. DETAILED DESCRIPTION
[0025] The present invention is further described in detail below in conjunction with specific embodiments and the accompanying drawings. Those of ordinary skill in the art will be able to implement the present invention based on these descriptions. In addition, the embodiments of the present invention involved in the following description are generally only embodiments of a part of the present invention, rather than all embodiments. Therefore, based on the embodiments in the present invention, all other embodiments obtained by those of ordinary skill in the art without making creative work should fall within the scope of protection of the present invention. Unless otherwise specified, the methods briefly described in the embodiments of the present invention are methods mastered by those skilled in the art.
[0026] Example 1
[0027] This embodiment provides a cross-contract asset transfer method, the method is used to transfer assets from a dynamic contract to a static contract, the method is applicable to a blockchain system, a management contract is configured in the blockchain system, the administrator of the blockchain system initiates a deposit transaction to deposit a contract account address for an asset transfer contract and a plurality of contract addresses of assets supporting cross-contract transfer in the management contract; the method comprises: an initiator initiates an asset locking transaction in a first contract and configures target asset information, the asset locking transaction is used to transfer a first quantity of first contract assets in the initiator's account address to the contract account address of the asset transfer contract and lock them, the target asset information comprises the contract address of a second contract asset, and the first contract is a dynamic contract;
[0028] The initiator initiates a minting transaction anchored to the asset locking transaction in the second contract, and packages the asset locking transaction and the minting transaction into an asset transfer transaction group and sends it to the blockchain system; the minting transaction is used to generate a second quantity of second contract assets in the second contract, the second quantity of second contract assets is equal to the first quantity of first contract assets, and the second contract is a static contract;
[0029] Executing the asset locking transaction;
[0030] The minting transaction is executed in the second contract, and the steps of the minting transaction include:
[0031] Parse the asset lock transaction to obtain first transaction information. The first transaction information includes the contract account address of the asset transfer contract, the first quantity, and the contract address of the second contract asset;
[0032] Calling the corresponding preset parameters in the management contract to verify the contract account address of the asset transfer contract and the contract address of the second contract asset in the first transaction information; the preset parameters are preset by the initiator based on the management contract before the transaction;
[0033] If the verification is passed, a minting operation is performed in the second contract to generate a second amount of second contract assets.
[0034] Preferably, the method also includes: the initiator issues a first transaction at the same time as the asset locking transaction and the coin minting transaction, and packages it together with the asset locking transaction and the coin minting transaction to add it to the asset transfer transaction group, the first transaction is used to transfer the generated second contract asset to the application transaction contract for asset trading; the application transaction contract is used for trading static contract assets.
[0035] Specifically, this embodiment takes the chain33 platform developed in GO language as an example. The platform deploys dynamic contracts - EVM contracts, management contracts - manage contracts, application transaction contracts - Exchange contracts, and asset transfer contracts - evmXgo contracts. The evmXgo contract is used to lock and unlock deposited assets when the contract assets are converted between the evm contract and the static native contract written in go language. The manage contract is used to configure management parameters, including the contract account address of the asset transfer contract. For example, the contract account address of the evmXgo contract needs to be stored in the manage contract, and the contract address of the asset that supports the conversion, which is generally the erc-20 contract address, which is used to characterize the corresponding digital asset. Taking the transfer of EVM contract assets as an example, the contract that uses the EVM virtual machine for state maintenance is the most common dynamic contract in the current blockchain technology. The static native contract is a contract written in the underlying language of the blockchain. Due to the overall performance requirements and other reasons, it cannot be deployed in the form of a dynamic contract. Therefore, there is a need for transfer between the two assets. The asset transfer method used in this embodiment is as follows: Figure 1 As shown, first, the initiator initiates an asset locking transaction in the EVM contract. By executing the asset locking transaction, a certain amount of EVM contract assets are transferred to the contract account address of the evmXgo contract and locked in it. Then, the initiator initiates the asset locking transaction and also a coin minting transaction. The coin minting transaction is created through the relevant transaction information of the asset locking transaction, including the locked contract account address, quantity and currency information to be converted. In this embodiment, the locked contract account address is the contract account address of the evmXgo contract, and the currency information is usually transmitted in the form of an erc20 contract address. When executing the coin minting transaction, it is necessary to confirm whether the information of the coin minting transaction is consistent with the information of the previous transaction in the transaction group, namely the asset locking transaction. If the verification is consistent, the coin minting operation can be performed. The verification operation is to prevent cheating in coin minting transactions. It is worth mentioning that the parameters in the coin minting transaction are obtained by parsing the previous transaction. Therefore, there is no need to configure the parameters of the coin minting transaction when initiating a coin minting transaction. Instead, the coin minting transaction and the previous asset locking transaction need to be combined into a transaction group and submitted to the blockchain. When executing the coin minting transaction, it is also necessary to call the contract account address stored in the manage contract and the contract address of the supported asset (usually the erc20 contract address) to verify the parameters parsed from the asset locking transaction, ensure that the asset is locked in the stored contract account address, and obtain the asset to be converted. Usually, the initiator is required to input the contract account address used and the contract address of the asset to be converted in advance before initiating the transaction for preliminary verification.
[0036] The ability to execute a minting transaction indicates that the previous asset locking transaction has been completed, which means that there are enough assets in the initiator's account to lock, and the locked address is correct. After the parsed parameters are verified, the minting operation is executed, and contract assets of equal value are generated in the corresponding contract.
[0037] In this embodiment, a first transaction is also initiated to transfer the minted assets directly into the application transaction contract - Exchange contract, in which the generated assets can be applied for trading. The asset transfer between static contracts written in the same language adopts conventional technical means, which will not be elaborated in this article. It should be noted that in order to achieve the generated assets can be directly applied to the Exchange contract, the initiated first contract also needs to form a transaction group with the above-mentioned asset locking transaction and coin minting transaction. The construction process of the transaction group of this embodiment is as follows: the asset transfer transaction, coin minting transaction and asset transfer transaction are stored in the transaction group in sequence, and each preceding transaction is designated as the parent transaction of the subsequent transaction, that is, the asset locking transaction is the parent transaction of the coin minting transaction, and the coin minting transaction is the parent transaction of the asset transfer transaction. The coin minting transaction needs to be executed after the asset locking transaction is executed, and the asset transfer transaction needs to be executed after the coin minting transaction is executed. Since the order of execution of the three transactions cannot be controlled if they are submitted separately, they are submitted in the form of a transaction group. Furthermore, the three transactions in the transaction group are from the asset transfer transaction in the transaction group to the asset transfer transaction. Yi starts to calculate the Hash value of the transaction. First, it calculates the Hash value of the asset transfer transaction and stores it in the minting transaction. Then it calculates the Hash value of the minting transaction and stores it in the asset locking transaction. Finally, it calculates the Hash value of the asset locking transaction and stores the Hash value of the asset locking transaction in the minting transaction and the asset transfer transaction. It calculates the SIGHASH of each transaction and calculates the signature to form the mutual relationship between the three transactions in the transaction group. If any transaction is deleted or modified from the transaction group, it is easy to determine that the transaction group has been modified, ensuring the correctness of the three transactions and the accuracy of cross-contract asset transfers.
[0038] On the other hand, when it is necessary to transfer assets from the Exchange contract or other GO language contracts back to the EVM contract, the following method is adopted: the initiator initiates an extraction transaction in the second contract and configures the return address, and the extraction transaction is used to transfer the third amount of the second contract assets to the contract account address of the asset transfer contract;
[0039] The initiator initiates a destruction transaction based on the withdrawal transaction in the asset transfer contract, and the destruction transaction is used to destroy the second contract asset in the contract account address transferred into the asset transfer contract;
[0040] The initiator submits the extraction transaction and destruction transaction to the blockchain system administrator;
[0041] The blockchain system administrator parses the parameters in the extraction transaction and the destruction transaction and generates an unlocking transaction, and submits the extraction transaction, the destruction transaction and the unlocking transaction into an asset unlocking transaction group to the blockchain system;
[0042] Based on the execution of the asset unlocking transaction group, a fourth quantity of the first contract assets in the contract account address of the asset transfer contract is unlocked and transferred to the return address.
[0043] It should be noted that the transaction group must be submitted by the administrator. The unlocking of assets in the contract account address requires the authorization of the administrator. Therefore, the final unlocking transaction must be signed by the administrator, and the parameters of the unlocking transaction are parsed and extracted from the previous transaction.
[0044] The extraction transaction, destruction transaction and unlocking transaction in the reflux process can also constitute a transaction group and be associated. The specific process of constructing a transaction group by the asset locking transaction, minting transaction and first transaction is similar and will not be repeated here.
[0045] The advantage of this embodiment is that, first of all, it realizes the asset transfer between heterogeneous contracts in the same blockchain network, that is, the asset transfer between dynamic contracts and static native contracts. At the same time, it strictly verifies the parameter settings of the previous and subsequent transactions to ensure that the coin minting operation is based on the previous asset locking transaction, and to ensure that there will be no cheating by minting out of thin air. Submitting transactions in the form of transaction groups can ensure that the transactions in the transfer process are executed in the required order, and the locked assets can be unlocked when the assets flow back, and there will be no situation where contract assets are minted while being locked.
[0046] Example 2
[0047] A computer device comprises: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the method described in Example 1.
[0048] A storage medium storing a computer program, which, when executed by a processor, implements the method described in the above embodiment 1.
[0049] Figure 2 A schematic diagram of the structure of a device provided in this embodiment.
[0050] like Figure 2As shown, as another aspect, the present application also provides a computer device 500, including one or more central processing units (CPU) 501, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 502 or the program loaded from the storage part 508 to the random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the device 500 are also stored. The CPU 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0051] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A driver 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the driver 510 as needed, so that a computer program read therefrom is installed into the storage section 508 as needed.
[0052] In particular, according to the embodiments disclosed in the present application, the method described in the above embodiment 1 can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program tangibly contained on a machine-readable medium, and the computer program includes a program code for executing the method described in any of the above embodiments. In such an embodiment, the computer program can be downloaded and installed from a network through the communication part 509, and / or installed from the removable medium 511.
[0053] As another aspect, the present application further provides a computer-readable storage medium, which may be a computer-readable storage medium included in the apparatus of the above embodiment; or a computer-readable storage medium that exists independently and is not assembled into the device. The computer-readable storage medium stores one or more programs, which are used by one or more processors to execute the method described in the present application.
[0054] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be realized by a dedicated hardware-based system that performs a specified function or operation, or can be realized by a combination of dedicated hardware and computer instructions.
[0055] The units or modules involved in the embodiments described in the present application may be implemented by software or by hardware. The units or modules described may also be arranged in a processor. For example, each of the units may be a software program arranged in a computer or a mobile smart device, or may be a separately configured hardware device. The names of these units or modules do not, in some cases, constitute limitations on the units or modules themselves.
[0056] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the concept of the present application. For example, the above features are replaced with the technical features with similar functions disclosed in the present application (but not limited to) to form a technical solution.
Claims
1. A cross-contract asset transfer method, characterized in that: The method is used to transfer assets from a dynamic contract to a static contract. The method is applicable to a blockchain system. A management contract is configured in the blockchain system. The administrator of the blockchain system initiates a deposit transaction to deposit a contract account address for an asset transfer contract and a plurality of contract addresses of assets supporting cross-contract transfer in the management contract. The method comprises: an initiator initiates an asset locking transaction in a first contract and configures target asset information. The asset locking transaction is used to transfer a first quantity of first contract assets in the initiator's account address to the contract account address of the asset transfer contract and lock the first contract. The target asset information includes the contract address of the second contract asset. The first contract is a dynamic contract. The initiator initiates a minting transaction anchored to the asset locking transaction in the second contract, and packages the asset locking transaction and the minting transaction into an asset transfer transaction group and sends it to the blockchain system; the minting transaction is used to generate a second quantity of second contract assets in the second contract, the second quantity of second contract assets is equal to the first quantity of first contract assets, and the second contract is a static contract; Executing the asset locking transaction; The minting transaction is executed in the second contract, and the steps of the minting transaction include: Parse the asset lock transaction to obtain first transaction information. The first transaction information includes the contract account address of the asset transfer contract, the first quantity, and the contract address of the second contract asset; Calling the corresponding preset parameters in the management contract to verify the contract account address of the asset transfer contract and the contract address of the second contract asset in the first transaction information; the preset parameters are preset by the initiator based on the management contract before the transaction; If the verification is passed, a minting operation is performed in the second contract to generate a second amount of second contract assets.
2. A cross-contract asset transfer method according to claim 1, characterized in that: The method also includes: the initiator issues a first transaction at the same time as the asset locking transaction and the coin minting transaction, and packages the first transaction together with the asset locking transaction and the coin minting transaction to add to the asset transfer transaction group, the first transaction is used to transfer the generated second contract asset to the application transaction contract for asset trading; the application transaction contract is used for trading static contract assets.
3. A cross-contract asset transfer method, characterized in that: The method is used to flow assets back from a static contract to a dynamic contract, and the method includes: an initiator initiates an extraction transaction in the second contract and configures a reflow address, and the extraction transaction is used to transfer a third amount of the second contract assets to the contract account address of the asset transfer contract; The initiator initiates a destruction transaction based on the withdrawal transaction in the asset transfer contract, and the destruction transaction is used to destroy the second contract asset in the contract account address transferred into the asset transfer contract; The initiator submits the extraction transaction and destruction transaction to the blockchain system administrator; The blockchain system administrator parses the parameters in the extraction transaction and the destruction transaction and generates an unlocking transaction, and submits the extraction transaction, the destruction transaction and the unlocking transaction into an asset unlocking transaction group to the blockchain system; Based on the execution of the asset unlocking transaction group, a fourth quantity of the first contract assets in the contract account address of the asset transfer contract is unlocked and transferred to the return address.
4. A computer device, characterized in that: one or more processors; a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors are caused to perform the method according to any one of claims 1 to 3.
5. A storage medium storing a computer program, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Fund transfer method and device and storage medium
CN109801167A
Data asset value evaluation device and method based on block chain
CN112258252A