A smart contract interaction method, device, equipment and storage medium
By querying and storing contract mapping relationships in blockchain networks, the cost and risk issues of contract address management in traditional smart contract interactions are solved, and development efficiency and security are improved.
Patent Information
- Application Number
- CN202111485117.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-07
- Publication Date
- 2024-12-24
- Estimated Expiration
- 2041-12-07
AI Technical Summary
Traditional smart contract interaction methods require users to store and memorize contract addresses themselves, resulting in increased storage costs, memory costs and management costs, and there is a risk of losing contract addresses and inaccessibility.
By extracting the target contract name from the contract deployment requirements, querying the blockchain network to obtain the historical mapping relationship, generating the contract version, and sending a deployment transaction request to the blockchain node to generate the contract address, storing the target mapping relationship to the blockchain network, Avoid users saving contract addresses.
Improves the efficiency of smart contract development, reduces costs and risks, and avoids the risk of inaccessibility due to loss of contract addresses.
Smart Images

Figure CN114168652B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of blockchain technology, and in particular to a smart contract interaction method, device, equipment, and storage medium. Background Art
[0002] The blockchain system is a decentralized distributed ledger with the characteristics of traceability, tamper-proof, anonymity and determinism. Smart contracts are programs deployed on the blockchain that can be automatically executed according to predetermined rules. The introduction of smart contracts has greatly expanded the application scenarios of blockchain.
[0003] The interaction process between users and smart contracts is generally as follows: first write a smart contract, then compile the smart contract to obtain the application binary interface file (Application Binary Interface, abi) that describes the contract interface, then deploy the smart contract to obtain a 20-byte contract address, after obtaining the contract address and abi file, pass in the corresponding parameters according to the interface in the contract and call it, and finally obtain the execution result of the smart contract. The traditional smart contract interaction method has the following disadvantages: First, users need to store the abi file by themselves, which increases the user's storage cost; second, users need to remember the contract address. If the contract address is lost, the contract will be inaccessible, which increases the user's memory cost and the risk of inaccessibility of the contract; third, after the user upgrades the smart contract version, the contract address needs to be maintained again, which increases the user's management cost. Summary of the invention
[0004] The present invention provides a smart contract interaction method, device, equipment and storage medium to improve the development efficiency of smart contracts and avoid the risk of being unable to access contracts due to contract loss.
[0005] In a first aspect, an embodiment of the present invention provides a smart contract interaction method, which is applied to a blockchain platform, and the method includes:
[0006] When it is determined that there is a contract deployment requirement, extracting a target contract name of the target smart contract from the contract deployment requirement;
[0007] According to the target contract name, query from the blockchain network to obtain the historical mapping relationship associated with the target contract name;
[0008] Generate a target contract version of the target smart contract according to the historical contract version in the historical mapping relationship;
[0009] Generate a contract deployment transaction request according to the contract deployment requirements;
[0010] Sending the contract deployment transaction request to the blockchain node to instruct the blockchain node to deploy the target smart contract according to the contract deployment transaction request and generate a target contract address of the target smart contract;
[0011] The target mapping relationship between the target contract name, the target contract version and the target contract address fed back by the blockchain node is stored in the blockchain network.
[0012] In a second aspect, an embodiment of the present invention further provides a smart contract interaction device, which is configured on a blockchain platform, and the device includes:
[0013] A target determination module, used to extract the target contract name of the target smart contract from the contract deployment requirement when it is determined that there is a contract deployment requirement; a historical mapping relationship determination module, used to query from the blockchain network according to the target contract name, and obtain the historical mapping relationship associated with the target contract name; a target contract version determination module, used to generate the target contract version of the target smart contract according to the historical contract version in the historical mapping relationship;
[0014] A deployment transaction request generation module, used to generate a contract deployment transaction request according to the contract deployment requirements;
[0015] A deployment transaction request sending module, used to send the contract deployment transaction request to the blockchain node to instruct the blockchain node to deploy the target smart contract according to the contract deployment transaction request and generate a target contract address of the target smart contract;
[0016] The target mapping relationship storage module is used to store the target mapping relationship between the target contract name, the target contract version and the target contract address fed back by the blockchain node in the blockchain network.
[0017] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:
[0018] 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 implement the smart contract interaction method provided in any embodiment of the present invention.
[0021] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a smart contract interaction method as provided in any embodiment of the present invention.
[0022] The technical solution of the embodiment of the present invention extracts the target contract name of the target smart contract from the contract deployment requirement when it is determined that there is a contract deployment requirement, queries from the blockchain network according to the target contract name, obtains the historical mapping relationship associated with the target contract name, generates the target contract version of the target smart contract according to the historical contract version in the historical mapping relationship, and generates a contract deployment transaction request according to the contract deployment requirement, and then sends a contract deployment transaction request to the blockchain node to instruct the blockchain node to deploy the target smart contract according to the contract deployment transaction request, and generates the target contract address of the target smart contract, and then stores the target mapping relationship between the target contract name, the target contract version and the target contract address fed back by the blockchain node in the blockchain network. The above technical solution does not require the user to save the contract address, avoids the risk of the user being unable to access the smart contract due to the loss of the contract address, improves the efficiency of the user in developing smart contracts, and reduces the cost and risk of smart contract development. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 is a flow chart of a smart contract interaction method provided in Embodiment 1 of the present invention;
[0024] Figure 2 is a flow chart of a smart contract interaction method provided by Embodiment 2 of the present invention;
[0025] Figure 3 is a flow chart of a smart contract interaction method provided by Embodiment 3 of the present invention;
[0026] Figure 4 It is a structural diagram of a smart contract interaction device provided by Embodiment 4 of the present invention;
[0027] Figure 5 It is a structural schematic diagram of an electronic device provided in Embodiment 5 of the present invention. DETAILED DESCRIPTION
[0028] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0029] Embodiment 1
[0030] Figure 1 This is a flowchart of a smart contract interaction method provided in Example 1 of the present invention. This embodiment is applicable to situations where smart contracts interact. The method can be executed by a smart interaction device, which can be implemented by software and / or hardware and can be integrated into a blockchain platform.
[0031] like Figure 1 As shown, the method may specifically include:
[0032] S110. When it is determined that there is a contract deployment requirement, extract the target contract name of the target smart contract from the contract deployment requirement; query the blockchain network based on the target contract name to obtain a historical mapping relationship associated with the target contract name; and generate a target contract version of the target smart contract based on the historical contract versions in the historical mapping relationship.
[0033] In this embodiment, the so-called contract deployment requirement refers to the requirement for contract deployment, which may include a smart contract file containing a target smart contract; wherein the target smart contract refers to a smart contract written by a user, which may include a target contract name, and further, may include a target contract version.
[0034] Specifically, when a user has a need to deploy a target smart contract, the user sends a contract deployment requirement to the blockchain platform; accordingly, upon receiving the contract deployment requirement, that is, upon determining that there is a contract deployment requirement, the blockchain platform determines the target contract name and target contract version of the target smart contract based on the contract deployment requirement.
[0035] An optional method is to extract the target contract name of the target smart contract from the contract deployment requirements, and then query the blockchain network based on the target contract name to obtain the historical mapping relationship associated with the target contract name, and then generate the target contract version of the target smart contract based on the historical contract version in the historical mapping relationship.
[0036] The historical mapping relationship refers to the mapping relationship between the target contract name, historical contract version and historical contract address stored in the blockchain network. It should be noted that the contract names of different versions of smart contracts stored in the blockchain network remain unchanged.
[0037] Specifically, the blockchain platform parses the content of the smart contract file in the contract deployment requirement, extracts the target contract name of the target smart contract, and then can query the blockchain network based on the mapping relationship query method, using the target contract name as an index, to obtain the historical mapping relationship associated with the target contract name, and then generate the target contract version of the target smart contract based on the historical contract version in the historical mapping relationship.
[0038] Exemplarily, the target contract version of the target smart contract is generated based on the historical contract version in the historical mapping relationship. If the target contract version of the target smart contract is extracted after parsing the contract deployment requirements, then a search is made in the historical mapping relationship to determine whether there is a historical contract version identical to the target smart contract; if so, the target contract version replaces the historical contract version.
[0039] Exemplarily, the target contract version of the target smart contract can be generated based on the historical contract versions in the historical mapping relationship. If the target contract version of the target smart contract is not extracted after parsing the contract deployment requirements, the version of the highest historical contract version in the historical mapping relationship plus 1 is used as the target contract version of the target smart contract.
[0040] S120. Generate a contract deployment transaction request according to the contract deployment requirements.
[0041] In this embodiment, the contract deployment transaction request refers to a request for instructing a blockchain node to deploy a contract. Optionally, the contract deployment transaction request may include a deployment file; wherein the deployment file refers to the file required by the blockchain node for deploying a smart contract, and may include an abi file and a bin file.
[0042] Specifically, the blockchain platform generates a contract deployment transaction request based on the user's contract deployment requirements.
[0043] An optional method is to extract the target smart contract from the contract deployment requirements, then compile the target smart contract to obtain the deployment file, and then generate a contract deployment transaction request including the deployment file.
[0044] Specifically, the blockchain platform can extract the target smart contract from the contract deployment requirements, compile the target smart contract, obtain the deployment file including the abi file and the bin file, and then generate a contract deployment transaction request containing the deployment file.
[0045] S130. Send a contract deployment transaction request to the blockchain node to instruct the blockchain node to deploy the target smart contract according to the contract deployment transaction request and generate a target contract address of the target smart contract.
[0046] In this embodiment, the target contract address is the physical address where the target smart contract is deployed on the blockchain node.
[0047] Specifically, the blockchain platform sends a contract deployment transaction request to the blockchain node; accordingly, the blockchain node deploys the target smart contract according to the contract deployment transaction request, generates a target contract address of the target smart contract, and then sends the target contract address to the blockchain platform.
[0048] S140. Store the target mapping relationship between the target contract name, the target contract version and the target contract address fed back by the blockchain node in the blockchain network.
[0049] In this embodiment, the target mapping relationship refers to the mapping relationship between the target contract address, the target contract version and the target contract address, which can be obtained by the mapping relationship recording method.
[0050] Optionally, when it is determined that a historical mapping relationship associated with the target contract name is stored in the blockchain network according to the target contract name, it is identified whether the target contract version is the same as the historical contract version in the historical mapping relationship. If they are the same, the target mapping relationship between the target contract name, the target contract version and the target contract address fed back by the blockchain node is used to replace the historical mapping relationship. If they are not the same, the target mapping relationship is stored in the blockchain network.
[0051] It should be noted that the mapping relationship recording method and mapping relationship query method in this embodiment are pre-stored in the precompiled contract. When the blockchain platform has a mapping relationship recording or mapping relationship query requirement, the mapping relationship method or mapping relationship query method in the precompiled contract will be automatically called to perform mapping relationship recording or query.
[0052] The technical solution of the embodiment of the present invention extracts the target contract name of the target smart contract from the contract deployment requirement when it is determined that there is a contract deployment requirement, queries from the blockchain network according to the target contract name, obtains the historical mapping relationship associated with the target contract name, generates the target contract version of the target smart contract according to the historical contract version in the historical mapping relationship, and generates a contract deployment transaction request according to the contract deployment requirement, and then sends a contract deployment transaction request to the blockchain node to instruct the blockchain node to deploy the target smart contract according to the contract deployment transaction request, and generates the target contract address of the target smart contract, and then stores the target mapping relationship between the target contract name, the target contract version and the target contract address fed back by the blockchain node in the blockchain network. The above technical solution does not require the user to save the contract address, avoids the risk of the user being unable to access the smart contract due to the loss of the contract address, improves the efficiency of the user in developing smart contracts, and reduces the cost and risk of smart contract development.
[0053] Embodiment 2
[0054] Figure 2 This is a flowchart of a smart contract interaction method provided in Example 2 of the present invention. Based on the above example, it is further optimized to provide an optional implementation plan.
[0055] like Figure 2 As shown, the method may specifically include:
[0056] S210. When it is determined that there is a contract deployment requirement, extract the target contract name of the target smart contract from the contract deployment requirement; query the blockchain network based on the target contract name to obtain the historical mapping relationship associated with the target contract name; and generate the target contract version of the target smart contract based on the historical contract version in the historical mapping relationship.
[0057] S220. Generate a contract deployment transaction request according to the contract deployment requirements.
[0058] S230. Send a contract deployment transaction request to the blockchain node to instruct the blockchain node to deploy the target smart contract according to the contract deployment transaction request and generate a target contract address of the target smart contract.
[0059] S240. Store the target mapping relationship between the target contract name, the target contract version and the target contract address fed back by the blockchain node in the blockchain network.
[0060] S250. When it is determined that there is a contract call requirement, determine the contract name and contract interface name of the smart contract to be called according to the contract call requirement.
[0061] In this embodiment, the contract call requirement refers to the requirement to call a smart contract. The contract call requirement may include the name of the contract to be called and the name of the contract interface to be called. Furthermore, it may also include the parameters required for the contract interface to be called, and optionally, it may also include the contract version to be called.
[0062] Among them, the name of the contract interface to be called refers to the name of the interface of the contract method in the smart contract to be called, and the parameters required for the contract to be called refer to the parameters required to implement the contract method in the smart contract to be called.
[0063] Specifically, when a user has a need to call a smart contract, he sends a contract call request to the blockchain platform; correspondingly, the blockchain platform receives the contract call request, that is, determines that there is a contract call request, parses the contract call request, and obtains the contract name to be called and the contract interface name to be called of the smart contract to be called.
[0064] S260. According to the name of the contract to be called, query from the blockchain network to obtain an available mapping relationship associated with the name of the contract to be called.
[0065] In this embodiment, the available mapping relationship refers to the mapping relationship associated with the contract name to be called that is already stored in the blockchain network and available for use.
[0066] Specifically, the blockchain platform automatically calls the mapping relationship query method in the precompiled contract based on the name of the contract to be called, queries the blockchain network, and obtains the available mapping relationship associated with the name of the contract to be called.
[0067] S270. Extract the contract address of the smart contract to be called from the available mapping relationship.
[0068] Specifically, the blockchain platform can extract the contract address to be called of the smart contract to be called from the available mapping relationship according to the contract version to be called.
[0069] An optional method is that if the contract version to be called is not obtained from the contract call requirement, the contract address of the highest contract version corresponding to the available mapping relationship is extracted as the contract address to be called of the smart contract to be called.
[0070] Another optional method is that if the contract version to be called is obtained from the contract call requirement, the contract address corresponding to the contract version to be called is extracted from the available mapping relationship as the contract address to be called of the smart contract to be called.
[0071] S280. Send a contract call request including the name of the contract interface to be called and the address of the contract to be called to the blockchain node, so that the blockchain node determines the smart contract to be called according to the address of the contract to be called, and executes the smart contract to be called according to the name of the contract interface to be called.
[0072] In this embodiment, the contract call request is used to instruct the blockchain node to execute the smart contract.
[0073] Specifically, after determining the address of the contract to be called, the blockchain platform generates a contract call request including the name of the contract interface to be called and the address of the contract to be called, and then sends the contract call request including the name of the contract interface to be called and the address of the contract to be called to the blockchain node; accordingly, the blockchain node determines the smart contract to be called according to the address of the contract to be called, and executes the smart contract to be called according to the name of the contract interface to be called, and then feeds back the execution result to the blockchain platform.
[0074] The technical solution of the embodiment of the present invention is to determine the contract name and the contract interface name of the smart contract to be called according to the contract call demand when it is determined that there is a contract call demand; query from the blockchain network according to the contract name to be called to obtain the available mapping relationship associated with the contract name to be called; extract the contract address of the smart contract to be called from the available mapping relationship; send a contract call request including the contract interface name and the contract address to be called to the blockchain node, so that the blockchain node determines the smart contract to be called according to the contract address to be called, and executes the smart contract to be called according to the contract interface name to be called. The above technical solution does not require users to save the contract address, and obtains the contract address from the blockchain network, avoiding the risk of users being unable to access the smart contract due to losing the contract address.
[0075] On the basis of the above embodiment, as an optional method of the embodiment of the present invention, the execution result of the smart contract to be called can also be obtained, and the execution result can be fed back to the demander of the contract call demand.
[0076] Specifically, the blockchain platform obtains the execution result of the smart contract to be called as fed back by the blockchain node, and feeds back the execution result to the demander who needs to call the contract.
[0077] Embodiment 3
[0078] Figure 3 This is a flow chart of a smart contract interaction method provided in Example 3 of the present invention. Based on the above embodiment, it is further optimized to provide a preferred solution.
[0079] like Figure 3 As shown, the method may specifically include:
[0080] S301. When a user has a business need, he writes a target smart contract and sends a contract deployment requirement including the target smart contract to the blockchain platform.
[0081] Specifically, when writing a target smart contract, the user can use preset rules or keywords to indicate the target contract version of the target smart contract. For example, a user writes a target smart contract Helloworld.sol, the target contract version is 1.0, and the contract contains a sayHello method. The expected return value of calling this method is "hello", that is, the execution result after executing the sayHello method is "hello".
[0082] S302. When the blockchain platform determines that there is a contract deployment requirement, the target contract name and target contract version of the target smart contract are determined according to the contract deployment requirement.
[0083] For example, the blockchain platform parses the target smart contract Helloworld.sol in the contract deployment requirements according to the contract deployment requirements, and obtains the target contract version 1.0 and the target contract name Helloworld.
[0084] S303. The blockchain platform generates a contract deployment transaction request according to the contract deployment requirements, and sends the contract deployment transaction request to the blockchain node.
[0085] S304. The blockchain node deploys the target smart contract according to the contract deployment transaction request and generates the target contract address of the target smart contract.
[0086] Specifically, the blockchain node deploys the target smart contract Helloworld.sol according to the deployment file in the contract deployment transaction request, and generates the target contract address of the target smart contract.
[0087] S305. The blockchain node sends the target contract address to the blockchain platform.
[0088] S306. The blockchain platform stores the target mapping relationship between the target contract name, the target contract version and the target contract address in the blockchain network.
[0089] S307. When the user has business needs, he sends a contract call request to the blockchain platform.
[0090] Specifically, the contract call requirements may include the name of the contract to be called Helloworld, the name of the contract interface to be called sayHello, the parameters required by the contract interface to be called, and if the interface does not require parameters, leave it blank. Optionally, it also includes the version number of the contract to be called 1.0.
[0091] S308. The blockchain platform receives a contract call requirement, and when determining that there is a contract call requirement, determines the contract name and contract interface name of the smart contract to be called according to the contract call requirement.
[0092] S309. The blockchain platform queries the blockchain network according to the name of the contract to be called, and obtains the available mapping relationship associated with the name of the contract to be called.
[0093] S310. The blockchain platform extracts the contract address to be called of the smart contract to be called from the available mapping relationship.
[0094] S311. The blockchain platform sends a contract call request including the name of the contract interface to be called and the address of the contract to be called to the blockchain node.
[0095] S312. The blockchain node determines the smart contract to be called according to the address of the contract to be called, executes the smart contract to be called according to the interface name of the contract to be called, and feeds back the execution result of the contract to be called to the blockchain platform.
[0096] S313. The blockchain platform feeds back the execution results to the user.
[0097] The technical solution of the embodiment of the present invention determines the target contract name and target contract version of the target smart contract according to the contract deployment requirements when it is determined that there is a contract deployment requirement, and generates a contract deployment transaction request according to the contract deployment requirements, and then sends the contract deployment transaction request to the blockchain node to instruct the blockchain node to deploy the target smart contract according to the contract deployment transaction request, and generates the target contract address of the target smart contract, and then stores the target mapping relationship between the target contract name, the target contract version and the target contract address fed back by the blockchain node in the blockchain network. The above technical solution does not require users to save the contract address, avoids the risk of users being unable to access the smart contract due to losing the contract address, improves the efficiency of users developing smart contracts, and reduces the cost and risk of smart contract development.
[0098] Embodiment 4
[0099] Figure 4 It is a structural diagram of a smart contract interaction device provided in Example 4 of the present invention. This embodiment can be applied to situations where smart contracts interact. The device can be implemented by software and / or hardware and can be integrated into a blockchain platform.
[0100] like Figure 4 As shown, the device may specifically include:
[0101] The target determination module 410 is used to extract the target contract name of the target smart contract from the contract deployment requirement when it is determined that there is a contract deployment requirement; query the blockchain network according to the target contract name to obtain the historical mapping relationship associated with the target contract name; and generate the target contract version of the target smart contract according to the historical contract version in the historical mapping relationship;
[0102] A deployment transaction request generation module 420 is used to generate a contract deployment transaction request according to contract deployment requirements;
[0103] A deployment transaction request sending module 430 is used to send a contract deployment transaction request to a blockchain node to instruct the blockchain node to deploy a target smart contract according to the contract deployment transaction request and generate a target contract address of the target smart contract;
[0104] The target mapping relationship storage module 440 is used to store the target mapping relationship between the target contract name, the target contract version and the target contract address fed back by the blockchain node in the blockchain network.
[0105] The technical solution of the embodiment of the present invention extracts the target contract name of the target smart contract from the contract deployment requirement when it is determined that there is a contract deployment requirement, queries from the blockchain network according to the target contract name, obtains the historical mapping relationship associated with the target contract name, generates the target contract version of the target smart contract according to the historical contract version in the historical mapping relationship, and generates a contract deployment transaction request according to the contract deployment requirement, and then sends a contract deployment transaction request to the blockchain node to instruct the blockchain node to deploy the target smart contract according to the contract deployment transaction request, and generates the target contract address of the target smart contract, and then stores the target mapping relationship between the target contract name, the target contract version and the target contract address fed back by the blockchain node in the blockchain network. The above technical solution does not require the user to save the contract address, avoids the risk of the user being unable to access the smart contract due to the loss of the contract address, improves the efficiency of the user in developing smart contracts, and reduces the cost and risk of smart contract development.
[0106] Furthermore, the deployment transaction request generation module 420 is specifically used for:
[0107] Extract the target smart contract from the contract deployment requirements;
[0108] Compile the target smart contract to obtain the deployment file;
[0109] Generate a contract deployment transaction request including deployment files.
[0110] Furthermore, the target mapping relationship storage module 440 is specifically used for:
[0111] When it is determined that a historical mapping relationship associated with the target contract name is stored in the blockchain network according to the target contract name, identifying whether the target contract version is the same as the historical contract version in the historical mapping relationship;
[0112] If they are the same, the target mapping relationship between the target contract name, target contract version and the target contract address fed back by the blockchain node is used to replace the historical mapping relationship.
[0113] Furthermore, the device also includes:
[0114] The module for determining the information to be called is used to determine the contract name to be called and the contract interface name to be called of the smart contract to be called according to the contract call requirement when it is determined that there is a contract call requirement;
[0115] An available mapping relationship acquisition module is used to query the blockchain network according to the contract name to be called, and obtain the available mapping relationship associated with the contract name to be called;
[0116] The module for determining the address of the contract to be called is used to extract the address of the smart contract to be called from the available mapping relationship;
[0117] The contract call request sending module is used to send a contract call request including the contract interface name to be called and the contract address to be called to the blockchain node, so that the blockchain node determines the smart contract to be called according to the contract address to be called, and executes the smart contract to be called according to the contract interface name to be called.
[0118] Furthermore, the module for determining the address of the contract to be called is specifically used for:
[0119] According to the version of the contract to be called, the contract address of the smart contract to be called is extracted from the available mapping relationship.
[0120] Furthermore, the device also includes:
[0121] The execution result feedback module is used to obtain the execution result of the smart contract to be called and feedback the execution result to the demander of the contract call demand.
[0122] The above-mentioned smart contract interaction device can execute the smart contract interaction method provided by any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution method.
[0123] Embodiment 5
[0124] Figure 5 is a structural diagram of an electronic device provided by Embodiment 5 of the present invention, Figure 5 A block diagram is shown of an exemplary apparatus suitable for implementing an exemplary embodiment of the present invention. Figure 5 The device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0125] like Figure 5 As shown, the electronic device 12 is in the form of a general purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that connects various system components (including the system memory 28 and the processing unit 16).
[0126] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. By way of example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0127] The electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0128] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory (cache 32). The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 5 not shown, usually called a "hard drive"). Although Figure 5 Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The system memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.
[0129] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. Program modules 42 generally perform the functions and / or methods of the embodiments described in the embodiments of the present invention.
[0130] The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), may communicate with one or more devices that enable a user to interact with the electronic device 12, and / or may communicate with any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via an input / output (I / O) interface 22. Furthermore, the electronic device 12 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 12 via a bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0131] The processing unit 16 executes various functional applications and data processing by running the programs stored in the system memory 28, such as implementing the smart contract interaction method provided in the embodiment of the present invention.
[0132] Embodiment 6
[0133] Embodiment 6 of the present invention further provides a computer-readable storage medium on which a computer program (or computer-executable instructions) is stored. When the program is executed by a processor, it is used to execute the smart contract interaction method provided in the embodiment of the present invention. The method includes:
[0134] When it is determined that there is a contract deployment requirement, determine the target contract name and target contract version of the target smart contract according to the contract deployment requirement;
[0135] Generate a contract deployment transaction request based on contract deployment requirements;
[0136] Send a contract deployment transaction request to the blockchain node to instruct the blockchain node to deploy the target smart contract according to the contract deployment transaction request and generate a target contract address of the target smart contract;
[0137] The target mapping relationship between the target contract name, the target contract version and the target contract address fed back by the blockchain node is stored in the blockchain network.
[0138] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, a device or a device or used in combination with it.
[0139] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0140] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0141] The computer program code for performing the operation of the embodiments of the present invention can be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., using an Internet service provider to connect through the Internet).
[0142] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the embodiments of the present invention are described in more detail through the above embodiments, the embodiments of the present invention are not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A smart contract interaction method, characterized in that: Applied to blockchain platforms, including: When it is determined that there is a contract deployment requirement, extracting a target contract name of the target smart contract from the contract deployment requirement; According to the target contract name, query from the blockchain network to obtain the historical mapping relationship associated with the target contract name; Generate a target contract version of the target smart contract according to the historical contract version in the historical mapping relationship; Generate a contract deployment transaction request according to the contract deployment requirements; Sending the contract deployment transaction request to the blockchain node to instruct the blockchain node to deploy the target smart contract according to the contract deployment transaction request and generate a target contract address of the target smart contract; The target mapping relationship between the target contract name, the target contract version and the target contract address fed back by the blockchain node is stored in the blockchain network; The generating a target contract version of the target smart contract according to the historical contract version in the historical mapping relationship includes: If the target contract version of the target smart contract is extracted after parsing the contract deployment requirements, then search from the historical mapping relationship whether there is a historical contract version identical to the target smart contract; if so, replace the historical contract version with the target contract version; If the target contract version of the target smart contract is not extracted after parsing the contract deployment requirements, the version obtained by adding 1 to the highest historical contract version in the historical mapping relationship is used as the target contract version of the target smart contract.
2. The method according to claim 1, characterized in that Generate a contract deployment transaction request according to the contract deployment requirements, including: Extracting a target smart contract from the contract deployment requirements; Compile the target smart contract to obtain a deployment file; Generate a contract deployment transaction request including the deployment file.
3. The method according to claim 1, characterized in that The storing the target mapping relationship between the target contract name, the target contract version and the target contract address fed back by the blockchain node in the blockchain network includes: When it is determined that a historical mapping relationship associated with the target contract name is stored in the blockchain network according to the target contract name, identifying whether the target contract version is the same as the historical contract version in the historical mapping relationship; If they are the same, the target mapping relationship between the target contract name, the target contract version and the target contract address fed back by the blockchain node is used to replace the historical mapping relationship.
4. The method according to claim 1, characterized in that: Also includes: When it is determined that there is a contract call requirement, determine the contract name to be called and the contract interface name to be called of the smart contract to be called according to the contract call requirement; According to the name of the contract to be called, query from the blockchain network to obtain an available mapping relationship associated with the name of the contract to be called; Extracting the to-be-called contract address of the to-be-called smart contract from the available mapping relationship; A contract call request including the contract interface name to be called and the contract address to be called is sent to the blockchain node, so that the blockchain node determines the smart contract to be called according to the contract address to be called, and executes the smart contract to be called according to the contract interface name to be called.
5. The method according to claim 4, characterized in that Extracting the to-be-called contract address of the to-be-called smart contract from the available mapping relationship includes: According to the version of the contract to be called, the contract address to be called of the smart contract to be called is extracted from the available mapping relationship.
6. The method according to claim 4, characterized in that Also includes: Obtain the execution result of the smart contract to be called, and feed back the execution result to the demander of the contract call demand.
7. A smart contract interaction device, characterized in that: Configured on the blockchain platform, including: A target determination module, configured to extract a target contract name of a target smart contract from the contract deployment requirement when it is determined that there is a contract deployment requirement; A historical mapping relationship determination module, used to query from the blockchain network according to the target contract name, and obtain the historical mapping relationship associated with the target contract name; A target contract version determination module, used to generate a target contract version of the target smart contract according to the historical contract version in the historical mapping relationship; A deployment transaction request generation module, used to generate a contract deployment transaction request according to the contract deployment requirements; A deployment transaction request sending module, used to send the contract deployment transaction request to the blockchain node to instruct the blockchain node to deploy the target smart contract according to the contract deployment transaction request and generate a target contract address of the target smart contract; A target mapping relationship storage module, used to store the target mapping relationship between the target contract name, the target contract version and the target contract address fed back by the blockchain node in the blockchain network; The target contract version determination module is specifically used to, if the target contract version of the target smart contract is extracted after parsing the contract deployment requirements, search from the historical mapping relationship whether there is a historical contract version identical to the target smart contract; if so, replace the historical contract version with the target contract version; If the target contract version of the target smart contract is not extracted after parsing the contract deployment requirements, the version obtained by adding 1 to the highest historical contract version in the historical mapping relationship is used as the target contract version of the target smart contract.
8. An electronic device, characterized in that: include: 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 implement the smart contract interaction method as described in any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the smart contract interaction method as described in any one of claims 1 to 6 is implemented.
