A blockchain smart contract seamless interaction method and system based on trusted relay
By adding transaction types and trusted relay modes to the blockchain execution layer, the senseless interaction of blockchain smart contracts is realized, which solves the problems of poor user experience and security risks, improves user experience and asset security, and avoids eliminate the risks of centralized servers.
Patent Information
- Application Number
- CN202410189504.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-20
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-02-20
AI Technical Summary
Existing blockchain smart contract interaction solutions have poor user experience and high security risks in high-frequency trading scenarios. Relying on private key wallets requires frequent authorization, and centralized servers have single-point failures and risks of asset leakage.
By adding transaction types to the blockchain execution layer, pre-saving Gas fees, using the trusted relay mode to interact seamlessly on the user side, generating user intention instructions and verifying them, creating a proxy wallet contract to calculate the fees, and realizing a decentralized server. interaction to improve user experience and security.
It achieves senseless interaction without changing the EVM blockchain consensus mechanism, improves user experience, improves scalability and asset security, and avoids the security risks of centralized servers.
Smart Images

Figure CN118075282B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular to a blockchain smart contract seamless interaction method based on a trusted relay and a blockchain smart contract seamless interaction system based on a trusted relay. Background Art
[0002] A smart contract is a piece of program code running on the blockchain. When a user calls a smart contract on the chain, he needs to use a user account controlled by a private key of an asymmetric encryption algorithm (EOA account for short), and send a call message by calling the on-chain API. The call message is signed with the private key of the EOA account to complete a contract call.
[0003] Currently, the following two solutions are usually used for contract calls:
[0004] The first solution is common. Usually, the user uses a blockchain wallet to manage the account private key and signature authorization transaction. For security reasons, the signature of each transaction is signed by the wallet pop-up window visualization interface. The transaction can only be executed after the user agrees to sign.
[0005] The second solution is that when using a blockchain application, the user sends the operation request to the centralized server of the application operator, and the EOA account managed by the operator acts as an agent to execute the contract call.
[0006] For solutions that rely on private key wallets to complete contract interactions, considering the security of account assets, it is impossible to allow wallets to privately call user private keys to sign transactions. Based on this, in high-frequency trading scenarios (such as games and social networking), it is necessary to frequently request user authorization, resulting in poor user experience and low transaction efficiency.
[0007] Although the proxy request solution based on centralized servers solves the problem of frequent authorization, it also brings security risks, such as single point failure of the server causing service unavailability, private key leakage due to server attacks, or active malicious actions by operators leading to user asset losses. Summary of the invention
[0008] In view of the above problems, the present invention provides a blockchain smart contract seamless interaction method and system based on trusted relay, which increases the blockchain transaction type in the blockchain execution layer and upgrades the blockchain wallet's support for the transaction type, thereby achieving seamless interaction on the user side without using a centralized server without changing the EVM blockchain consensus mechanism, thereby improving the user experience without reducing the security of user assets, and abstracting the signature, verification and fee deduction logic on the user side through the repeater mode, thereby improving scalability.
[0009] To achieve the above object, the present invention provides a blockchain smart contract seamless interaction method based on trusted relay, comprising:
[0010] Pre-deploy a relay contract in the blockchain and pre-deposit Gas fees based on the relay contract;
[0011] Generate a user intention instruction according to the user operation action and send it to the blockchain node, and the blockchain node sends the received user intention instruction to the intention instruction pool and broadcasts it on the blockchain at the same time;
[0012] When the trusted repeater monitors the user's intended instruction, it verifies the validity of the user's intended instruction;
[0013] Execute the verified user intention instruction as a transaction and create a proxy wallet contract for the corresponding user;
[0014] The proxy wallet contract calls the relay contract according to the user's intended instruction, calculates the handling fee for the instruction execution process, and the relay contract transfers the fee;
[0015] The execution logic corresponding to the transaction is packaged and sent to the transaction pool, and is executed on the chain by the accounting node.
[0016] In the above technical solution, preferably, generating a user intention instruction according to the user operation action specifically includes:
[0017] According to the acquired user operation action, determine the target contract address to be called, the name of the target contract, the parameters to be passed, the transaction sender, the gas fee, the signature and the signature verification public key, and generate the user intention instruction;
[0018] Based on a preset signature verification mechanism, the signature is used to perform a signing operation on the user intent instruction so that the trusted repeater can verify the signature.
[0019] In the above technical solution, preferably, when the trusted repeater monitors the user intention instruction, the specific process of verifying the validity of the user intention instruction includes:
[0020] The validity of the signature of the user's intended instruction is verified, the required Gas fee is estimated, and the validity of the pre-stored Gas fee is verified based on the estimated Gas fee.
[0021] In the above technical solution, preferably, the proxy wallet contract calls the relay contract according to the user intention instruction, calculates the handling fee of the instruction execution process, and the specific process of the fee transfer by the relay contract includes:
[0022] The proxy wallet contract executes the user intention instruction, and calls the target method of the target contract according to the user intention instruction, passing the corresponding parameters;
[0023] The Gas fee required to execute the user's intended instruction is calculated according to the target method and the parameters, and the relay contract transfers the Gas fee to the corresponding user account.
[0024] In the above technical solution, preferably, the specific process of packaging the execution logic corresponding to the transaction and sending it to the transaction pool, and having the accounting node execute the execution logic on the chain includes:
[0025] Through the relay contract, a transaction is created based on the EOA account corresponding to the user intention instruction, and the execution logic corresponding to the user intention instruction is packaged and sent to the transaction pool, waiting for the accounting node of the blockchain to verify the transaction in the transaction pool and perform the chain operation.
[0026] The present invention also proposes a blockchain smart contract seamless interaction system based on a trusted relay, which uses a blockchain smart contract seamless interaction method based on a trusted relay as disclosed in any one of the above technical solutions, including:
[0027] The contract deployment module is used to pre-deploy the relay contract in the blockchain and pre-deposit the gas fee based on the relay contract;
[0028] An instruction generation module is used to generate a user intention instruction according to a user operation action and send it to a blockchain node. The blockchain node sends the received user intention instruction to an intention instruction pool and broadcasts it on the blockchain at the same time;
[0029] An instruction verification module, used to verify the validity of the user's intended instruction when the trusted repeater monitors the user's intended instruction;
[0030] A transaction execution module, used to execute the verified user intention instruction as a transaction and create a proxy wallet contract for the corresponding user;
[0031] The relay extension module is used to use the proxy wallet contract to call the relay contract according to the user's intention instruction, calculate the handling fee of the instruction execution process, and transfer the fee by the relay contract;
[0032] The transaction chain module is used to package the execution logic corresponding to the transaction and send it to the transaction pool, and the accounting node executes it on the chain.
[0033] In the above technical solution, preferably, the instruction generation module is specifically used to:
[0034] According to the acquired user operation action, determine the target contract address to be called, the name of the target contract, the parameters to be passed, the transaction sender, the gas fee, the signature and the signature verification public key, and generate the user intention instruction;
[0035] Based on a preset signature verification mechanism, the signature is used to perform a signing operation on the user intent instruction so that the trusted repeater can verify the signature.
[0036] In the above technical solution, preferably, the instruction verification module is specifically used to:
[0037] The validity of the signature of the user's intended instruction is verified, the required Gas fee is estimated, and the validity of the pre-stored Gas fee is verified based on the estimated Gas fee.
[0038] In the above technical solution, preferably, the relay extension module is specifically used for:
[0039] The proxy wallet contract executes the user intention instruction, and calls the target method of the target contract according to the user intention instruction, passing the corresponding parameters;
[0040] The Gas fee required to execute the user's intended instruction is calculated according to the target method and the parameters, and the relay contract transfers the Gas fee to the corresponding user account.
[0041] In the above technical solution, preferably, the transaction on-chain module is specifically used for:
[0042] Through the relay contract, a transaction is created based on the EOA account corresponding to the user intention instruction, and the execution logic corresponding to the user intention instruction is packaged and sent to the transaction pool, waiting for the accounting node of the blockchain to verify the transaction in the transaction pool and perform the chain operation.
[0043] Compared with the prior art, the beneficial effects of the present invention are as follows: by adding blockchain transaction types at the blockchain execution layer and upgrading the blockchain wallet's support for the transaction type, it is possible to achieve seamless interaction on the user side without using a centralized server without changing the EVM blockchain consensus mechanism, thereby improving the user experience without reducing the security of user assets, and abstracting the signature, verification and fee deduction logic on the user side through the repeater mode, thereby improving scalability. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 A flowchart of a blockchain smart contract seamless interaction method based on a trusted relay disclosed in an embodiment of the present invention;
[0045] Figure 2 A schematic diagram of the execution logic of a relay contract disclosed in an embodiment of the present invention;
[0046] Figure 3 A schematic diagram of a module of a blockchain smart contract seamless interaction system based on a trusted relay disclosed in an embodiment of the present invention.
[0047] In the figure, the corresponding relationship between each component and the reference numeral is as follows:
[0048] 1. Contract deployment module, 2. Instruction generation module, 3. Instruction verification module, 4. Transaction execution module, 5. Relay extension module, 6. Transaction on-chain module. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0050] The present invention is further described in detail below in conjunction with the accompanying drawings:
[0051] like Figure 1 As shown, a blockchain smart contract seamless interaction method based on a trusted relay provided by the present invention includes:
[0052] Pre-deploy the relay contract in the blockchain and pre-deposit the gas fee based on the relay contract;
[0053] Generate user intent instructions based on user operation actions and send them to the blockchain node. The blockchain node sends the received user intent instructions to the intent instruction pool and broadcasts them on the blockchain at the same time;
[0054] When the trusted repeater monitors the user's intended instruction, it verifies the validity of the user's intended instruction;
[0055] Execute the verified valid user intention instructions as transactions and create a proxy wallet contract for the corresponding user;
[0056] The proxy wallet contract calls the relay contract according to the user's intended instructions, calculates the handling fee for the instruction execution process, and the relay contract transfers the fee;
[0057] The execution logic corresponding to the transaction is packaged and sent to the transaction pool, and then executed on the chain by the accounting node.
[0058] In this implementation, by adding blockchain transaction types at the blockchain execution layer and upgrading the blockchain wallet's support for the transaction type, it is achieved that without changing the EVM blockchain consensus mechanism, user-side seamless interaction is achieved without using a centralized server, thereby improving the user experience while not reducing the security of user assets. The repeater mode is used to abstract the signature, verification, and fee deduction logic on the user side, thereby improving scalability.
[0059] Specifically, the transaction process includes the transfer of assets on the blockchain and the call of contracts. Among them, the transaction pool (TX_Pool) contains all transactions signed by the user's EOA account private key. The nodes of the blockchain are used to maintain the operation of the blockchain network and publish on the chain. Among them, the nodes that obtain the right to record can take out transactions from the transaction pool for verification, execution, packaging, and publishing on the chain (blocking). Other nodes verify and execute the published blocks to reach a consensus.
[0060] Among them, the user intention instruction (U_OP) is an abstract description of the operation that the user wants to perform, such as the contract address called, method name, passed parameters, etc. The user intention instruction pool (OP_Pool) is similar to the transaction pool TX_Pool, but the signature traded by the user intention instruction pool is not the private key signature of the user EOA. The signature only needs to be supported by the repeater for signature verification.
[0061] Among them, the trusted relay is used to monitor OP_Pool, verify and execute new user instructions, and finally package transactions on the chain. Trust means that the relay can be run by any role. Blockchain nodes, application operators, or dedicated relay operators can all run as relay roles, and users can choose freely. Trusted relays do not operate user assets, but only perform operations according to user instructions and charge fees.
[0062] The relay contract is a smart contract pre-deployed on the chain. It is the entry point for executing user instructions. It is mainly responsible for assisting the relayer to complete the legality verification of user instructions and the pre-deposit of user gas fees. The proxy wallet is essentially a smart contract. The ownership of the contract belongs to the EOA account to which the user sends the instruction. It has the function of executing the contract call on behalf of the user's EOA according to the user's instructions and maintaining the nonce (a random number, also a transaction counter, representing the current transaction number of the wallet to prevent transaction replay attacks). The proxy wallet replaces the user's EOA account to complete the contract call according to the user's instructions and receive the user's settlement assets.
[0063] During the implementation process, users need to use the traditional transaction transfer method to deposit fees into the relay contract as the handling fee for executing instructions. The relay contract maintains the wallet address of the pre-deposited handling fee and the pre-deposited fee.
[0064] In the above implementation, preferably, in the process of generating the user intention instruction according to the user operation action:
[0065] According to the acquired user operation action, determine the target contract address to be called, the name of the target contract, the parameters to be passed, the transaction sender, the gas fee, the signature and the signature verification public key, and generate the user intention instruction;
[0066] Based on the preset signature verification mechanism, the user's intended instruction is signed using the signature so that the trusted repeater can verify the signature.
[0067] Specifically, the signature is not the user's EOA account private key signature. The wallet needs to generate a bunch of asymmetric encryption keys for the user and manage them locally, and use the newly generated private key to sign the instruction information. The key algorithm can support users to configure on the wallet side. Different key generation algorithms and signature methods are configured according to the selected trusted repeaters. The signature only requires the wallet to prove to the repeater that the instruction initiator is the user himself.
[0068] like Figure 2 As shown, in the above implementation, preferably, when the blockchain node receives the user intent instruction, it puts it into the intent instruction pool OP_Pool and broadcasts it on the blockchain. When the trusted repeater monitors the broadcasted user intent instruction, it verifies the validity of the user intent instruction. The specific process includes:
[0069] The signature of the user's intended instruction is verified for validity, the required Gas fee is estimated, and the pre-deposited Gas fee is verified for validity based on the estimated Gas fee to ensure that the user's intended instruction is a valid transaction before execution.
[0070] In the above implementation, preferably, the proxy wallet contract calls the relay contract according to the user's intention instruction, calculates the handling fee of the instruction execution process, and the specific process of the relay contract transferring the fee includes:
[0071] After the trusted relay verifies that the user's intent instruction has passed, the user's intent instruction is executed as a transaction, a proxy wallet contract is created for the message sender, and the proxy wallet owner is set as the instruction sender. The user's intent instruction is executed by the proxy wallet contract, and the proxy wallet calls the target method of the target contract as MsgSender according to the user's intent instruction, passing the corresponding parameters;
[0072] The Gas fee required to execute the user's intended instructions is calculated based on the target method and parameters, and the relay contract transfers the Gas fee (pre-deposited Gas fee) to the corresponding user account.
[0073] In the above implementation, preferably, the execution logic corresponding to the transaction is packaged and sent to the transaction pool, and the specific process of the accounting node executing the on-chain includes:
[0074] Through the relay contract, a transaction is created based on the EOA account corresponding to the user's intention instruction, and the execution logic corresponding to the user's intention instruction is packaged and sent to the transaction pool TX_Pool, waiting for the blockchain's accounting node to verify the transaction in the transaction pool and perform the on-chain operation.
[0075] like Figure 3 As shown, the present invention also proposes a blockchain smart contract seamless interaction system based on a trusted relay, which applies the blockchain smart contract seamless interaction method based on a trusted relay disclosed in any one of the above embodiments, including:
[0076] Contract deployment module 1 is used to pre-deploy the relay contract in the blockchain and pre-deposit the gas fee based on the relay contract;
[0077] Instruction generation module 2, used to generate user intention instructions according to user operation actions and send them to the blockchain node. The blockchain node sends the received user intention instructions to the intention instruction pool and broadcasts them on the blockchain at the same time;
[0078] The instruction verification module 3 is used to verify the validity of the user's intended instruction when the trusted repeater monitors the user's intended instruction;
[0079] Transaction execution module 4, used to execute the verified valid user intention instruction as a transaction and create a proxy wallet contract for the corresponding user;
[0080] Relay extension module 5 is used to use the proxy wallet contract to call the relay contract according to the user's intention instruction, calculate the handling fee of the instruction execution process, and transfer the fee by the relay contract;
[0081] The transaction chain module 6 is used to package the execution logic corresponding to the transaction and send it to the transaction pool, and the accounting node executes it on the chain.
[0082] In this implementation, by adding blockchain transaction types at the blockchain execution layer and upgrading the blockchain wallet's support for the transaction type, it is achieved that without changing the EVM blockchain consensus mechanism, user-side seamless interaction is achieved without using a centralized server, thereby improving the user experience while not reducing the security of user assets. The repeater mode is used to abstract the signature, verification, and fee deduction logic on the user side, thereby improving scalability.
[0083] In the above implementation, preferably, the instruction generation module 2 is specifically used for:
[0084] According to the acquired user operation action, determine the target contract address to be called, the name of the target contract, the parameters to be passed, the transaction sender, the gas fee, the signature and the signature verification public key, and generate the user intention instruction;
[0085] Based on the preset signature verification mechanism, the user's intended instruction is signed using the signature so that the trusted repeater can verify the signature.
[0086] In the above implementation, preferably, the instruction verification module 3 is specifically used for:
[0087] The signature of the user's intended instruction is verified for validity, the required Gas fee is estimated, and the pre-deposited Gas fee is verified for validity based on the estimated Gas fee.
[0088] In the above implementation, preferably, the relay extension module 5 is specifically used for:
[0089] The proxy wallet contract executes the user's intended instruction, and calls the target method of the target contract according to the user's intended instruction, passing the corresponding parameters;
[0090] The Gas fee required to execute the user's intended instructions is calculated based on the target method and parameters, and the relay contract transfers the Gas fee to the corresponding user account.
[0091] In the above implementation, preferably, the transaction on-chain module 6 is specifically used for:
[0092] Through the relay contract, a transaction is created based on the EOA account corresponding to the user's intention instruction, and the execution logic corresponding to the user's intention instruction is packaged and sent to the transaction pool, waiting for the blockchain's accounting node to verify the transaction in the transaction pool and perform the on-chain operation.
[0093] According to the blockchain smart contract seamless interaction system based on trusted relay disclosed in the above-mentioned implementation mode, the functions to be implemented by each module thereof correspond to the implementation steps of the blockchain smart contract seamless interaction method based on trusted relay disclosed in the above-mentioned implementation mode. During the implementation process, operations are performed with reference to the above-mentioned implementation mode, which will not be repeated here.
[0094] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A blockchain smart contract seamless interaction method based on trusted relay, It is characterized in that include: Pre-deploy a relay contract in the blockchain and pre-deposit Gas fees based on the relay contract; Generate a user intention instruction according to the user operation action and send it to the blockchain node, and the blockchain node sends the received user intention instruction to the intention instruction pool and broadcasts it on the blockchain at the same time; When the trusted relay monitors the user's intended instruction, it verifies the validity of the user's intended instruction. The specific process includes: verifying the validity of the signature of the user's intended instruction, estimating the required Gas fee, and verifying the validity of the pre-stored Gas fee based on the estimated Gas fee; Execute the verified valid user intention instruction as a transaction and create a proxy wallet contract for the corresponding user; The proxy wallet contract calls the relay contract according to the user intention instruction, calculates the handling fee of the instruction execution process, and the relay contract transfers the fee. The specific process includes: the proxy wallet contract executes the user intention instruction, uses the user intention instruction as the target method to call the target contract, and passes the corresponding parameters; calculates the Gas handling fee required to execute the user intention instruction according to the target method and the parameters, and the relay contract transfers the Gas handling fee to the corresponding user account; The execution logic corresponding to the transaction is packaged and sent to the transaction pool, and is executed on the chain by the accounting node.
2. According to the blockchain smart contract seamless interaction method based on trusted relay according to claim 1, It is characterized in that Generating a user intention instruction according to a user operation action specifically includes: According to the acquired user operation action, determine the target contract address to be called, the name of the target contract, the parameters to be passed, the transaction sender, the gas fee, the signature and the signature verification public key, and generate the user intention instruction; Based on a preset signature verification mechanism, the signature is used to sign the user intent instruction so that the trusted repeater can verify the signature.
3. According to the blockchain smart contract seamless interaction method based on trusted relay according to claim 1, It is characterized in that The specific process of packaging the execution logic corresponding to the transaction and sending it to the transaction pool, and having the accounting node execute the on-chain execution includes: Through the relay contract, a transaction is created based on the EOA account corresponding to the user intention instruction, and the execution logic corresponding to the user intention instruction is packaged and sent to the transaction pool, waiting for the accounting node of the blockchain to verify the transaction in the transaction pool and perform the chain operation.
4. A blockchain smart contract seamless interaction system based on trusted relay, It is characterized in that The blockchain smart contract seamless interaction method based on a trusted relay as claimed in any one of claims 1 to 3 is applied, comprising: The contract deployment module is used to pre-deploy the relay contract in the blockchain and pre-deposit the gas fee based on the relay contract; An instruction generation module is used to generate a user intention instruction according to a user operation action and send it to a blockchain node. The blockchain node sends the received user intention instruction to an intention instruction pool and broadcasts it on the blockchain at the same time; The instruction verification module is used to verify the validity of the user's intended instruction when the trusted repeater monitors the user's intended instruction, specifically for: Verify the validity of the signature of the user's intended instruction, estimate the required Gas fee, and verify the validity of the pre-stored Gas fee based on the estimated Gas fee; A transaction execution module, used to execute the verified user intention instruction as a transaction and create a proxy wallet contract for the corresponding user; The relay extension module is used to use the proxy wallet contract to call the relay contract according to the user's intention instruction, calculate the handling fee of the instruction execution process, and transfer the fee by the relay contract, specifically for: The proxy wallet contract executes the user intention instruction, and uses the user intention instruction as the target method to call the target contract and pass the corresponding parameters; Calculate the Gas fee required to execute the user's intended instruction according to the target method and the parameters, and transfer the Gas fee to the corresponding user account by the relay contract; The transaction chain module is used to package the execution logic corresponding to the transaction and send it to the transaction pool, and the accounting node executes it on the chain.
5. According to the blockchain smart contract non-sensing interaction system based on trusted relay according to claim 4, It is characterized in that The instruction generation module is specifically used for: According to the acquired user operation action, determine the target contract address to be called, the name of the target contract, the parameters to be passed, the transaction sender, the gas fee, the signature and the signature verification public key, and generate the user intention instruction; Based on a preset signature verification mechanism, the signature is used to sign the user intent instruction so that the trusted repeater can verify the signature.
6. According to claim 4, the blockchain smart contract non-sensing interaction system based on trusted relay, It is characterized in that The transaction on-chain module is specifically used for: Through the relay contract, a transaction is created based on the EOA account corresponding to the user intention instruction, and the execution logic corresponding to the user intention instruction is packaged and sent to the transaction pool, waiting for the accounting node of the blockchain to verify the transaction in the transaction pool and perform the chain operation.
