Electronic commerce system based on block chain
By adopting blockchain network sharding technology and smart contract technology in the e-commerce system, the existing system's trust and throughput in fresh food, agricultural products and other industries has been solved, and efficient and secure transaction processing and data storage have been achieved.
Patent Information
- Application Number
- CN202411782412.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-03-28
AI Technical Summary
The existing e-commerce systems have problems such as low trust, high logistics losses, and untrustworthy transaction intermediates in fresh food, agricultural products and other industries, and have large throughput, making it difficult to improve system security and throughput at the same time.
The blockchain-based e-commerce system is adopted to process transaction data through blockchain network sharding technology, use Java's web3j class library to interact with smart contracts, and combine it with MySQL database storage facilities to realize parallel transaction processing and distributed data storage.
It significantly improves transaction processing speed and throughput, ensures the authenticity and integrity of product information, user information, and order information, and realizes automatic, efficient and secure transaction execution through smart contracts, enhancing data security.
Smart Images

Figure CN119720242A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of e-commerce, and in particular to an e-commerce system based on blockchain. Background Art
[0002] Blockchain is a distributed ledger technology based on cryptography principles that uses a chain block structure to store data. At present, with the rapid development of my country's e-commerce and logistics industries, the existing e-commerce system has a high operating efficiency.
[0003] In particular, industries such as fresh food and agricultural products have gradually embarked on the development path of fresh food e-commerce. However, in the rapid development of e-commerce in fresh food and agricultural products, many problems have been exposed, such as low consumer trust in fresh product information, high logistics losses, and untrustworthy intermediaries in transactions. Therefore, the e-commerce system established based on blockchain technology has a more secure transaction attribute, can achieve decentralization, and solves the problem of untrustworthy intermediaries. However, for e-commerce systems, their throughput is large; therefore, how to further improve the throughput of e-commerce systems while ensuring a certain degree of security in e-commerce systems is a problem that needs to be solved at present. Summary of the invention
[0004] To this end, the present invention provides an e-commerce system based on blockchain to solve the problems in the prior art.
[0005] In order to achieve the above object, the present invention provides the following technical solutions:
[0006] An e-commerce system based on blockchain, including application layer, middle layer and data layer.
[0007] The application layer uses a Web interface to provide users with a visual operation interface, so that users can interact with the e-commerce system; the application layer is divided into an account management module, a transaction module and an information query module according to its functions;
[0008] The middle layer uses Java's web3j class library, which is written in Java to implement the functions of deploying and calling contracts under the Maven framework. web3j connects to smart contracts. When a user requests a transaction, the transaction is sent to web3j through the front end of the Web server. The interaction with the smart contract is implemented through the web3j class library. Specifically, web3j sends the transaction request and user signature to the smart contract, and the smart contract returns the transaction result to web3j. web3j feeds the result back to the Web server.
[0009] The data layer is composed of a blockchain network and a MySQL database as storage facilities; the PoS sharding protocol is used to shard the transaction data in the e-commerce system, and the network is divided to form network shards; each shard is responsible for processing a part of the transaction, and the product information, user information, and order information in the e-commerce system are distributed and stored in each shard of the blockchain network;
[0010] The application layer connects to the MySQL database via the JBDC driver.
[0011] Further: the account management module includes blockchain network account registration, shopping website account registration, wallet password verification and login management module.
[0012] Further: the transaction module includes a buyer application module and a seller application module. The seller application module is used to implement operations such as creating products, adding product quantities, and refunding. The buyer application is used to implement operations such as browsing products, purchasing products, signing for transactions, and returning products.
[0013] Further: the information query module is used to query shopping website account information and user blockchain account information.
[0014] Further: the smart contract includes blockchain account information query, blockchain account registration, adding goods, purchasing goods, and signing for goods.
[0015] Further: The specific steps of blockchain network sharding are as follows:
[0016] (1) Sharding network nodes based on verifiable delay functions;
[0017] (2) Select the shard leader and final committee leader, and determine the final committee members;
[0018] (3) The final committee leader forwards the transaction to the shard leader; the large number of transactions generated by the final committee leader will be evenly distributed to the shard leader;
[0019] (4) The shard leader packages the received transactions into a transaction microblock, calculates the leader node of the next packaged transaction microblock in the shard, and then broadcasts the transaction microblock and the public key of the next leader node to the shard member nodes;
[0020] (5) Shard members perform Practical Byzantine Fault Tolerance (PBFT) consensus to verify transactions and verify the correctness of the next shard leader node;
[0021] (6) The shard leader collects the verification results of the shard member nodes and sends the transaction microblock to the final committee leader;
[0022] (7) The final committee leader collects the transaction microblocks of each shard, assembles them into transaction blocks, and calculates the final leader node;
[0023] (8) The final committee members conduct practical Byzantine fault-tolerant consensus verification of the education block and verify the correctness of the final leader node;
[0024] (9) Finally, the committee leader adds the verified transaction block to the transaction blockchain and broadcasts the new block to all shard leader nodes; at this time, it is necessary to determine whether the current epoch has ended;
[0025] (10) If the epoch ends, the shard leader will update the blockchain status after receiving the new block and broadcast the transaction block to the member nodes in the shard; after receiving the new block information, the shard members will update the new block to the blockchain;
[0026] (11) If the epoch has not ended, return to step (3) until the epoch ends.
[0027] Furthermore: the shard member node can independently run a verifiable delay function to calculate a random number, and the calculated random number is unique.
[0028] Further: The specific steps of network node sharding are as follows:
[0029] 1) Initialize the security parameter λ with the private key and set the delay time t;
[0030] 2) Each node runs the initialization function Setup and generates the calculation parameter ek and the verification parameter vk; the calculation formula of the Setup function is as follows:
[0031] Setup(sk,t)=(ek,vk);
[0032] In the formula, sk represents the private key;
[0033] 3) After the parameters are initialized, each node uses the hash value of the public key as input, runs the calculation function Eval of the verifiable delay function, and broadcasts the calculation result y for verification by other nodes;
[0034] 4) Each node runs the verification function Verify that can verify the delay function; if the verification fails, the calculation result y is discarded;
[0035] 5) If the verification is successful, the calculation result y is added to the node set;
[0036] 6) Sort the nodes from large to small according to the y value, generate an index list, and then get the shard number Si of each node by index mod m; where m represents the number of shards;
[0037] 7) Select the shard leader and the final committee; compare the y values of all shard leaders, and the shard with the largest y value is selected as the final committee. The leader is the leader of the final committee, and the members of the shard are the members of the final committee.
[0038] Furthermore: a verification mechanism is designed when the client of the application layer logs in.
[0039] The present invention has the following advantages: Through the blockchain network sharding technology, the transaction data in the e-commerce system can be processed by sharding; each shard is responsible for processing a part of the transaction, thereby realizing parallel processing of transactions and significantly improving the processing speed and throughput of transactions. By utilizing the immutability of the blockchain, the authenticity and integrity of data such as product information, user information, and order information can be ensured. At the same time, through the smart contract technology, the execution of transactions in the shards is automatic, efficient, and secure, further enhancing the security of the data.
[0040] Other features and advantages of the present invention will be set forth in the description which follows, and in part will be apparent from the description, or may be learned by practicing the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more intuitively illustrate the prior art and the present application, exemplary drawings are given below. It should be understood that the specific shapes and structures shown in the drawings should not generally be regarded as limiting conditions for implementing the present application; for example, those skilled in the art are capable of easily making conventional adjustments or further optimizations to the addition / reduction / attribution division, specific shapes, positional relationships, connection methods, dimensional ratios, etc. of certain units (components) based on the technical concepts and exemplary drawings disclosed in the present application.
[0042] Figure 1 A system block diagram of a blockchain-based e-commerce system provided by the present invention.
[0043] Figure 2 An interaction sequence diagram of an e-commerce system based on blockchain provided by the present invention.
[0044] Figure 3 A schematic diagram of the operation flow of blockchain network sharding in the e-commerce system provided by the present invention.
[0045] Figure 4 A schematic diagram of the blockchain node sharding process in the e-commerce system provided by the present invention.
[0046] FIG5( a ) is a schematic diagram of the structure of the transaction throughput when the number of shards is 12 in an embodiment of the present invention.
[0047] FIG5( b ) is a schematic diagram of the structure of the transaction throughput when the number of shards is 6 in an embodiment of the present invention.
[0048] FIG5(c) is a schematic diagram of the structure of the transaction throughput when the number of shards is 4 in an embodiment of the present invention. DETAILED DESCRIPTION
[0049] The following is an explanation of the implementation of the present invention by specific specific examples. People familiar with this technology can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. Obviously, the described embodiments are part of the embodiments of the present invention, not all of them. It should be understood that these embodiments are only to further illustrate the present invention and cannot be understood as limiting the scope of protection of the present invention. Technical engineers in this field can make some non-essential improvements and adjustments to the present invention based on the contents of the above invention; 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] See also Figure 1 , an e-commerce system based on blockchain, adopts a framework combining B / S architecture with distribution, including application layer, middle layer and data layer;
[0051] The application layer uses a Web interface to provide users with a visual operation interface, so that users can interact with the e-commerce system; the application layer is divided into an account management module, a transaction module and an information query module according to its functions.
[0052] The account management module includes blockchain network account registration, shopping website account registration, wallet password verification and login management module.
[0053] The transaction module includes a buyer application module and a seller application module. The seller application module can be used to implement operations such as creating products, adding product quantities, and refunding. The buyer application can be used to implement operations such as browsing products, purchasing products, signing for transactions, and returning products.
[0054] The information query module can be used to query shopping website account information and user blockchain account information.
[0055] The middle layer adopts Java's web3j class library and implements the functions of deploying and calling contracts under the Maven framework through Java language. Web3j connects smart contracts.
[0056] The smart contract includes blockchain account information query, blockchain account registration, adding goods, purchasing goods, signing for goods, etc.
[0057] The data layer consists of a blockchain network and a MySQL database as storage facilities. The transaction data in the e-commerce system can be processed in shards, with each shard responsible for processing a part of the transaction, thereby improving the efficiency of transaction processing; through smart contract technology, it is ensured that the execution of transactions in the shards is automatic, efficient and secure; in addition, the product information, user information, order information, etc. in the e-commerce system can be distributed and stored in each shard of the blockchain network. In this way, the authenticity and integrity of the data are ensured by utilizing the immutability of the blockchain.
[0058] The application layer connects to the MySQL database via a JBDC driver (Java Database Connectivity driver, JDBC is a set of Java APIs for executing SQL statements).
[0059] In this embodiment, in order to further protect the security of users, a verification mechanism is designed when the client of the application layer logs in, and a verification code is used to prevent DDos attacks.
[0060] like Figure 2 As shown in the figure, when a user requests a transaction, the transaction will be sent to web3j through the front end of the Web server. The interaction with the smart contract is implemented through the web3j class library. Specifically, web3j will send the transaction request and user signature to the smart contract, and the smart contract will return the transaction result to web3j; web3j will feed back the result to the Web server.
[0061] like Figure 3 As shown in the figure, in order to improve the scalability of the blockchain, the PoS sharding protocol is used to split transactions into transaction shards, and the network is divided to form network shards; the specific steps of blockchain network sharding are as follows:
[0062] (1) Sharding network nodes based on verifiable delay functions;
[0063] (2) Select the shard leader and final committee leader, and determine the final committee members;
[0064] (3) The final committee leader forwards the transaction to the shard leader; the large number of transactions generated by the final committee leader will be evenly distributed to the shard leader;
[0065] (4) The shard leader packages the received transactions into a transaction microblock, calculates the leader node of the next packaged transaction microblock in the shard, and then broadcasts the transaction microblock and the public key of the next leader node to the shard member nodes;
[0066] (5) Shard members perform Practical Byzantine Fault Tolerance (PBFT) consensus to verify transactions and verify the correctness of the next shard leader node;
[0067] (6) The shard leader collects the verification results of the shard member nodes and sends the transaction microblock to the final committee leader;
[0068] (7) The final committee leader collects the transaction microblocks of each shard, assembles them into transaction blocks, and calculates the final leader node;
[0069] (8) The final committee members conduct practical Byzantine fault-tolerant consensus verification of the education block and verify the correctness of the final leader node;
[0070] (9) Finally, the committee leader adds the verified transaction block to the transaction blockchain and broadcasts the new block to all shard leader nodes; at this time, it is necessary to determine whether the current epoch has ended;
[0071] (10) If the epoch ends, the shard leader will update the blockchain status after receiving the new block and broadcast the transaction block to the member nodes in the shard; after the shard members receive the new block information, they will update the new block to the blockchain.
[0072] (11) If the epoch has not ended, return to step (3) until the epoch ends.
[0073] For the network node sharding based on the verifiable delay function in step (1), each node can independently run the verifiable delay function to calculate a random number, and the calculated random number is unique, so that the sharding result has randomness.
[0074] Each node can independently calculate the private key hash value. The specific sharding steps are as follows: Figure 4 As shown:
[0075] 1) Initialize the security parameter λ with the private key and set the delay time t;
[0076] 2) Each node runs the initialization function Setup and generates the calculation parameter ek and the verification parameter vk; the calculation formula of the Setup function is as follows:
[0077] Setup(sk,t)=(ek,vk);
[0078] In the formula, sk represents the private key;
[0079] 3) After the parameters are initialized, each node uses the hash value of the public key as input, runs the calculation function Eval of the verifiable delay function, and broadcasts the calculation result y for verification by other nodes;
[0080] 4) Each node runs the verification function Verify that can verify the delay function; if the verification fails, the calculation result y is discarded;
[0081] 5) If the verification is successful, the calculation result y is added to the node set;
[0082] 6) Sort the nodes from large to small according to the y value, generate an index list, and then get the shard number Si of each node by index mod m; where m represents the number of shards;
[0083] 7) Select the shard leader and the final committee; compare the y values of all shard leaders, and the shard with the largest y value is selected as the final committee. The leader is the leader of the final committee, and the members of the shard are the members of the final committee.
[0084] Based on the above network sharding scheme, assuming that there are 2400 nodes in the whole network, it is now divided into 12 shards, 6 shards and 4 shards for testing. The number of nodes in each shard is 200, 400 and 600 respectively; and each transaction block is set to contain 4096 transactions. The final committee leader will evenly distribute the transactions in each block to all shards, and finally assemble them into transaction blocks by the final committee leader; the transaction throughput is tested according to 30 epochs, and the results are as follows: Figure 5(a) , 5(b) and 5(c).,From the results in Figure 5, it can be seen that the transaction,throughput has been in a high processing state.
[0085] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. An e-commerce system based on blockchain, comprising an application layer, an intermediate layer and a data layer, characterized in that: The application layer uses a Web interface to provide users with a visual operation interface, so that users can interact with the e-commerce system; the application layer is divided into an account management module, a transaction module and an information query module according to its functions; The middle layer uses Java's web3j class library, which is written in Java to implement the functions of deploying and calling contracts under the Maven framework. web3j connects to smart contracts. When a user requests a transaction, the transaction is sent to web3j through the front end of the Web server. The interaction with the smart contract is implemented through the web3j class library. Specifically, web3j sends the transaction request and user signature to the smart contract, and the smart contract returns the transaction result to web3j. web3j feeds the result back to the Web server. The data layer consists of a blockchain network and a MySQL database as storage facilities; The PoS sharding protocol is used to shard the transaction data in the e-commerce system and divide the network into network shards. Each shard is responsible for processing a part of the transaction. The product information, user information, and order information in the e-commerce system are distributed and stored in each shard of the blockchain network. The application layer connects to the MySQL database via the JBDC driver.
2. The blockchain-based e-commerce system according to claim 1, characterized in that: The account management module includes blockchain network account registration, shopping website account registration, wallet password verification and login management module.
3. The blockchain-based e-commerce system according to claim 1, characterized in that: The transaction module includes a buyer application module and a seller application module. The seller application module is used to implement operations such as creating products, adding product quantities, and refunding. The buyer application is used to implement operations such as browsing products, purchasing products, signing for transactions, and returning products.
4. The blockchain-based e-commerce system according to claim 1, characterized in that: The information query module is used to query shopping website account information and user blockchain account information.
5. The blockchain-based e-commerce system according to claim 1, characterized in that: The smart contract includes blockchain account information query, blockchain account registration, adding goods, purchasing goods, and signing for goods.
6. The blockchain-based e-commerce system according to claim 1, characterized in that: The specific steps of sharding the blockchain network are as follows: (1) Sharding network nodes based on verifiable delay functions; (2) Select the shard leader and final committee leader, and determine the final committee members; (3) The final committee leader forwards the transaction to the shard leader; the large number of transactions generated by the final committee leader will be evenly distributed to the shard leader; (4) The shard leader packages the received transactions into a transaction microblock, calculates the leader node of the next packaged transaction microblock in the shard, and then broadcasts the transaction microblock and the public key of the next leader node to the shard member nodes; (5) Shard members verify transactions through Practical Byzantine Fault Tolerance consensus and verify the correctness of the next shard leader node; (6) The shard leader collects the verification results of the shard member nodes and sends the transaction microblock to the final committee leader; (7) The final committee leader collects the transaction microblocks of each shard, assembles them into transaction blocks, and calculates the final leader node; (8) The final committee members conduct practical Byzantine fault-tolerant consensus verification of the education block and verify the correctness of the final leader node; (9) Finally, the committee leader adds the verified transaction block to the transaction blockchain and broadcasts the new block to all shard leader nodes; at this time, it is necessary to determine whether the current epoch has ended; (10) If the epoch ends, the shard leader will update the blockchain status after receiving the new block and broadcast the transaction block to the member nodes in the shard; after receiving the new block information, the shard members will update the new block to the blockchain; (11) If the epoch has not ended, return to step (3) until the epoch ends.
7. The blockchain-based e-commerce system according to claim 6, characterized in that: The shard member nodes can independently run a verifiable delay function to calculate a random number, and the calculated random number is unique.
8. The blockchain-based e-commerce system according to claim 6, characterized in that: The specific steps of network node sharding are as follows: 1) Initialize the security parameter λ with the private key and set the delay time t; 2) Each node runs the initialization function Setup and generates the calculation parameter ek and the verification parameter vk; the calculation formula of the Setup function is as follows: Setup(sk,t)=(ek,vk); In the formula, sk represents the private key; 3) After the parameters are initialized, each node uses the hash value of the public key as input, runs the calculation function Eval of the verifiable delay function, and broadcasts the calculation result y for verification by other nodes; 4) Each node runs the verification function Verify that can verify the delay function; if the verification fails, the calculation result y is discarded; 5) If the verification is successful, the calculation result y is added to the node set; 6) Sort the nodes from large to small according to the y value, generate an index list, and then get the shard number Si of each node by index mod m; where m represents the number of shards; 7) Select the shard leader and the final committee; compare the y values of all shard leaders, and the shard with the largest y value is selected as the final committee. The leader is the leader of the final committee, and the members of the shard are the members of the final committee.
9. The blockchain-based e-commerce system according to claim 1, characterized in that: A verification mechanism is designed when the client of the application layer logs in.