A Blockchain Transaction Behavior Prediction Method Based on Graph Neural Networks

By constructing a blockchain transaction graph using graph neural network algorithms and random walk methods, the problem of difficulty in expressing node link relationships in existing technologies is solved, enabling efficient and accurate prediction of blockchain transaction behavior, which is suitable for the supervision of blockchain transaction behavior.

CN117557265BActive Publication Date: 2026-11-17TIANJIN UNIVERSITY OF TECHNOLOGY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311428161.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-31
Publication Date
2026-11-17
Estimated Expiration
2043-10-31

AI Technical Summary

Technical Problem

Existing technologies struggle to effectively represent the node connections in a blockchain transaction graph, resulting in insufficient accuracy in predicting blockchain transaction behavior.

Method used

A graph neural network algorithm is used to construct a blockchain transaction graph and predict transaction behavior using a random walk method. Factors such as transaction amount and time are considered. A data dictionary and label matrix are used to divide the graph into subgraphs, and a loss function is defined to improve prediction accuracy.

Benefits of technology

It significantly reduces execution time and memory consumption, improves the accuracy and average accuracy of transaction prediction, and helps to effectively regulate blockchain transactions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117557265B_ABST
    Figure CN117557265B_ABST
Patent Text Reader

Abstract

This invention relates to a blockchain transaction behavior prediction method based on graph neural networks, comprising: 1) acquiring blockchain data, and simultaneously preprocessing and storing the blockchain data; 2) constructing a blockchain transaction graph from the blockchain transaction dataset; 3) partitioning the blockchain transaction graph into subgraphs; 4) predicting unweighted graph transactions using a transaction behavior prediction method based on graph neural networks and random walks; and 5) predicting weighted graph transactions using a transaction behavior prediction method based on graph neural networks and random walks. The prediction method of this invention significantly reduces execution time and memory consumption, and fully considers factors such as transaction amount, transaction time, and others, while greatly improving prediction accuracy and average accuracy. It also has a wide applicability, applicable to mainstream public blockchain systems such as Bitcoin, EOS, and Polkadot, contributing to effective supervision of blockchain transaction behavior.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of machine learning and data mining technology, specifically relating to a method for predicting blockchain transaction behavior based on graph neural networks. Background Technology

[0002] Blockchain technology has made significant progress, with various industries adopting it as an underlying technology. This will inevitably lead to a massive amount of data appearing in blockchain form. Therefore, studying blockchain data is of great importance. Because blockchain systems protect user privacy through anonymous transactions, analyzing blockchain data to infer user transaction behavior and predict transactions is a crucial issue in blockchain data mining. Different experts and scholars have conducted research on various methods for predicting blockchain transaction behavior, thereby achieving relatively accurate predictions.

[0003] Traditional methods for predicting and characterizing trading behavior based on trading charts include the following: 1) Machine learning methods based on feature extraction.

[0004] 2) A method for predicting abnormal transaction behavior in blockchain based on graph learning algorithms.

[0005] 3) Cascade-based machine learning methods.

[0006] All of these algorithms are executed on the blockchain transaction graph. Furthermore, current feature extraction methods typically consider statistical information such as the in-degree and out-degree of the transacting parties or the number of transactions initiated. This information is often insufficient to represent the node connections within the blockchain transaction graph. Summary of the Invention

[0007] The purpose of this invention is to overcome the shortcomings of the prior art and provide a blockchain transaction behavior prediction method based on graph neural networks. By using graph neural network algorithms in the transaction subgraph, the connection relationship between nodes in the transaction graph can be expressed, which can effectively and quickly predict blockchain transaction behavior.

[0008] The technical problem solved by this invention is achieved through the following technical solution: A blockchain transaction behavior prediction method based on graph neural networks, characterized in that: the method comprises the following steps: 1) Build the blockchain mainnet, configure the network interface, obtain blockchain data, and at the same time preprocess and store the blockchain data to obtain the blockchain transaction dataset; 2) Construct a blockchain transaction graph from the blockchain transaction dataset using a data dictionary-based transaction graph construction algorithm; 3) The blockchain transaction graph is divided into subgraphs using a transaction subgraph construction algorithm based on the label matrix; 4) Predict unweighted graph trading behavior using a trading behavior prediction method based on graph neural networks and random walks; 5) Predict transaction behavior in a weighted graph using a transaction behavior prediction method based on graph neural networks and random walks.

[0009] Furthermore, the specific method for step 1) is as follows: using Ethereum JSON RPC to obtain blockchain transaction data. First, a Go Ethereum connection is set up to connect to the blockchain mainnet. The blockchain's HTTP interface is implemented through Ethereum RPC configuration. Then, a web crawler is written to analyze the blockchain transaction data. Data acquisition, preprocessing, and storage are performed to obtain a blockchain transaction dataset. ; including blockchain transaction dataset The data structure includes: sequence number , Enter address Output address Transaction volume timestamp .

[0010] Furthermore, the specific method for step 2) is as follows: 201) Using the aforementioned blockchain transaction dataset , to enter address and output address As nodes, each blockchain data entry's transaction relationships form edges, using transaction amounts... and timestamp As weights, construct the input address Point to the output address Directed graph of blockchain transactions ; 202) Directed graph of blockchain transactions Extraction and preprocessing are performed; 203) Due to the input address of the transaction and output address The 32-byte string format makes node name access difficult; therefore, a data dictionary is used to analyze the directed graph of blockchain transactions. Re-marking is performed; this process creates a blockchain transaction data dictionary table. and the re-tagged blockchain transaction data table ; including the blockchain transaction data dictionary table Includes: number Transaction address ; Re-tagged blockchain transaction data table Includes: serial number , Enter address sequence number Output address sequence number Transaction volume timestamp Simultaneously, the blockchain transaction data table was re-tagged. Input address sequence number and output address sequence number The stored content is a blockchain transaction data dictionary table. number ; 204) In the re-tagged blockchain transaction data table Based on this, construct a blockchain transaction graph ; where the input address sequence number and output address sequence number Blockchain transaction diagram Nodes in and Constructing a system of nodes point to edge ,side The weight of the edge ,side Time attribute Because a data dictionary is used to visualize the directed graph of blockchain transactions. Re-marking is performed, therefore reading The relabeled blockchain transaction graph, represented as a transaction graph matrix W: The element in its i-th row and j-th column is ,Right now Chinese representative of and representatives of Row number Simultaneously forming the transaction time matrix T: The element in the i-th row and j-th column is ; 205) Simultaneous Blockchain Transaction Diagram Includes: nodes ,node ,side weight of the edge The time attribute of the edge n represents the total number of nodes.

[0011] Furthermore, the specific method for step 3) is as follows: 301) Assume the label matrix S is composed of edges corresponding id value constitute: 302) If a node exists point to edge ,but: in: This represents the element in the k-th row of matrix S; 303) For all edges After performing the above operations, the label matrix S is rearranged, and the same labels are sorted out. Values ​​are marked using the smallest row number: The label matrix S is rearranged into ascending order using a swap sorting algorithm. When swapping the m-th and n-th rows, the m-th and n-th rows, as well as the m-th and n-th columns, of the adjacency matrices W and T are also swapped. After this adjustment, the adjacency matrices W and T will be transformed into block diagonal matrix forms. : Furthermore, the specific method for step 4) is as follows: 401) The random walk method was initially defined on a strongly connected and aperiodic directed graph G containing n nodes. Assuming graph G is unweighted, the transition matrix is: 402) If node The out-degree is k, and the node One of the incoming edges starts at node . Then the transition matrix The element in the i-th row and j-th column: Therefore, 403) Assume that the initial weights of all nodes in the random walk are equal, i.e. 404) Then the random walk model based on graph G can be expressed as: Then R is the final result of the random walk, i.e. in The weights of each node after the random walk are easily obtained as follows: in: Indicates pointing to The set of nodes, Represents a node The set of connected nodes; 405) From the construction of the transaction subgraph, it can be seen that the graph is not a strongly connected graph, that is, the columns of the transition matrix are 0. Therefore, the limit of the random walk is: 406) To avoid the case where the limit value does not exist, a damping factor d is defined empirically. If d is close to 1, the random walk mainly follows the transition matrix. If d is close to 0, the random walk visits any node in the graph with equal probability. The formula for calculating the result of the random walk is: Based on experience, the value d is usually taken as 0.85, which can avoid the problem that the limit of random walk does not exist.

[0012] Furthermore, the specific method for step 5) is as follows: 501) If we consider random walks in a weighted graph, the probability of a node walking is proportional to the weight of the outgoing edges. Assume a transaction subgraph. For a weighted graph, its adjacency matrix is: 502) The transition matrix has the same form as formula (3.7), but the element values ​​in the matrix are: in: Indicates by If we consider the change of the transition matrix over time for the set of nodes it points to, then a time coefficient needs to be introduced: 503) The formula for calculating the result of a random walk is: 504) In a graph neural network, suppose the features of node v are The features on edge (u, v) are The computation is performed node-by-node and edge-by-edge according to the following message passing paradigm: 505) is calculated from the above formula. and compute nodes and Link coefficients between : 506) Based on the link coefficient Define a loss function, using cross-entropy loss: in: This represents the Sigmoid function.

[0013] 507) Determine whether the loss value exceeds the threshold. If it does not exceed the threshold, repeat steps 504)-507) to achieve transaction prediction.

[0014] The advantages and beneficial effects of this invention are as follows: 1. Compared with traditional search methods, the proposed transaction subgraph partitioning method based on graph neural networks significantly reduces execution time and memory consumption.

[0015] 2. The method of the present invention fully considers factors such as transaction amount, transaction time and other factors in blockchain, and at the same time significantly improves prediction accuracy and average accuracy.

[0016] 3. The method of the present invention helps to achieve effective supervision of blockchain transaction behavior. Attached Figure Description

[0017] Figure 1 This is a flowchart of the present invention; Figure 2 This is a flowchart illustrating the construction process of the blockchain transaction graph in this invention. Figure 3 This is a flowchart illustrating the blockchain transaction subgraph partitioning process of this invention. Figure 4 This is a flowchart illustrating the prediction process for unweighted graph transaction behavior according to the present invention. Figure 5 This is a flowchart illustrating the process of predicting rights map transaction behavior according to the present invention. Figure 6 This invention uses real Ethereum transaction data to construct a blockchain transaction graph; Figure 7 This is a memory usage graph of the transaction subgraph partitioning algorithm of this invention; Figure 8 This diagram illustrates the accuracy of blockchain transaction behavior prediction according to the present invention. Detailed Implementation

[0018] The present invention will be further described in detail below through specific embodiments. The following embodiments are merely descriptive and not limiting, and should not be used to limit the scope of protection of the present invention.

[0019] An innovative method for predicting blockchain transaction behavior based on graph neural networks is described below, with the following steps: 1) Build the blockchain mainnet, configure the network interface, obtain blockchain data, and at the same time preprocess and store the blockchain data to obtain the blockchain transaction dataset; 2) Construct a blockchain transaction graph from the blockchain transaction dataset using a data dictionary-based transaction graph construction algorithm; 3) The blockchain transaction graph is divided into subgraphs using a transaction subgraph construction algorithm based on the label matrix; 4) Predict unweighted graph trading behavior using a trading behavior prediction method based on graph neural networks and random walks; 5) Predict transaction behavior in a weighted graph using a transaction behavior prediction method based on graph neural networks and random walks.

[0020] The specific method for step 1) is as follows: Use Ethereum JSON RPC to obtain blockchain transaction data. First, a Go Ethereum connection is set up to connect to the blockchain mainnet. The blockchain's HTTP interface is implemented through Ethereum RPC configuration. Then, a web crawler is written to analyze the blockchain transaction data. Data acquisition, preprocessing, and storage are performed to obtain a blockchain transaction dataset. ; including blockchain transaction dataset The data structure includes: sequence number , Enter address Output address Transaction volume timestamp .

[0021] The specific method for step 2) is as follows: 201) Using the aforementioned blockchain transaction dataset , to enter address and output address As nodes, each blockchain data entry's transaction relationships form edges, using transaction amounts... and timestamp As weights, construct the input address Point to the output address Directed graph of blockchain transactions ; 202) Directed graph of blockchain transactions Extraction and preprocessing are performed; 203) Due to the input address of the transaction and output address The 32-byte string format makes node name access difficult; therefore, a data dictionary is used to analyze the directed graph of blockchain transactions. Re-marking is performed; this process creates a blockchain transaction data dictionary table. and the re-tagged blockchain transaction data table ; including the blockchain transaction data dictionary table Includes: number Transaction address ; Re-tagged blockchain transaction data table Includes: serial number , Enter address sequence number Output address sequence number Transaction volume timestamp Simultaneously, the blockchain transaction data table was re-tagged. Input address sequence number and output address sequence number The stored content is a blockchain transaction data dictionary table. number ; 204) In the re-tagged blockchain transaction data table Based on this, construct a blockchain transaction graph ; where the input address sequence number and output address sequence number Blockchain transaction diagram Nodes in and Constructing a system of nodes point to edge ,side The weight of the edge ,side Time attribute Because a data dictionary is used to visualize the directed graph of blockchain transactions. Re-marking is performed, therefore reading The relabeled blockchain transaction graph, represented as a transaction graph matrix W: The element in its i-th row and j-th column is ,Right now Chinese representative of and representatives of Row number Simultaneously forming the transaction time matrix T: The element in the i-th row and j-th column is ; Simultaneously, the blockchain transaction diagram Includes: nodes ,node ,side weight of the edge The time attribute of the edge n represents the total number of nodes.

[0022] The specific method for step 3) is as follows: 301) Assume the label matrix S is composed of edges corresponding id value constitute: 302) If a node exists point to edge ,but: in: This represents the element in the k-th row of matrix S; 303) For all edges After performing the above operations, the label matrix S is rearranged, and the same labels are sorted out. Values ​​are marked using the smallest row number: The label matrix S is rearranged into ascending order using a swap sorting algorithm. When swapping the m-th and n-th rows, the m-th and n-th rows, as well as the m-th and n-th columns, of the adjacency matrices W and T are also swapped. After this adjustment, the adjacency matrices W and T will be transformed into block diagonal matrix forms. : The specific method for step 4) is as follows: 401) The random walk method was initially defined on a strongly connected and aperiodic directed graph G containing n nodes. Assuming graph G is unweighted, the transition matrix is: 402) If node The out-degree is k, and the node One of the incoming edges starts at node . Then the transition matrix The element in the i-th row and j-th column: Therefore, 403) Assume that the initial weights of all nodes in the random walk are equal, i.e. 404) Then the random walk model based on graph G can be expressed as: Then R is the final result of the random walk, i.e. in The weights of each node after the random walk are easily obtained as follows: in: Indicates pointing to The set of nodes, Represents a node The set of connected nodes; 405) From the construction of the transaction subgraph, it can be seen that the graph is not a strongly connected graph, that is, the columns of the transition matrix are 0. Therefore, the limit of the random walk is: 406) To avoid the case where the limit value does not exist, a damping factor d is defined empirically. If d is close to 1, the random walk mainly follows the transition matrix. If d is close to 0, the random walk visits any node in the graph with equal probability. The formula for calculating the result of the random walk is: Based on experience, the value d is usually taken as 0.85, which can avoid the problem that the limit of random walk does not exist.

[0023] The specific method for step 5) is as follows: 501) If we consider random walks in a weighted graph, the probability of a node walking is proportional to the weight of the outgoing edges. Assume a transaction subgraph. For a weighted graph, its adjacency matrix is: 502) The transition matrix has the same form as formula (3.7), but the element values ​​in the matrix are: in: Indicates by If we consider the change of the transition matrix over time for the set of nodes it points to, then a time coefficient needs to be introduced: 503) The formula for calculating the result of a random walk is: 504) In a graph neural network, suppose the features of node v are The features on edge (u, v) are The computation is performed node-by-node and edge-by-edge according to the following message passing paradigm: 505) is calculated from the above formula. and compute nodes and Link coefficients between : 506) Based on the link coefficient Define a loss function, using cross-entropy loss: in: This represents the Sigmoid function.

[0024] 507) Determine whether the loss value exceeds the threshold. If it does not exceed the threshold, repeat steps 504)-507) to achieve transaction prediction.

[0025] The method described in this invention obtains real Ethereum transaction data, and after labeling and reconstruction, constructs a blockchain transaction graph, such as... Figure 6 As shown.

[0026] The transaction subgraph partitioning algorithm of this invention can significantly reduce the average memory footprint of the algorithm, such as... Figure 7 As shown, Algorithm 1 is the classic algorithm, Algorithm 2 is the optimized algorithm, and Algorithm 3 is the algorithm proposed in this invention.

[0027] like Figure 8 As shown, the present invention can effectively improve the accuracy of transaction behavior prediction.

[0028] Although embodiments and drawings of the present invention have been disclosed for illustrative purposes, those skilled in the art will understand that various substitutions, variations and modifications are possible without departing from the spirit and scope of the present invention and the appended claims. Therefore, the scope of the present invention is not limited to the contents disclosed in the embodiments and drawings.

Claims

1. A blockchain transaction behavior prediction method based on graph neural networks, characterized in that: The steps of the method are as follows: 1) Build the blockchain mainnet, configure the network interface, obtain blockchain data, and at the same time preprocess and store the blockchain data to obtain the blockchain transaction dataset; 2) Construct a blockchain transaction graph from the blockchain transaction dataset using a data dictionary-based transaction graph construction algorithm; 3) The blockchain transaction graph is divided into subgraphs using a transaction subgraph construction algorithm based on the label matrix; 4) Predict unweighted graph trading behavior using a trading behavior prediction method based on graph neural networks and random walks; 5) Predict transaction behavior in a weighted graph using a transaction behavior prediction method based on graph neural networks and random walks; The specific method for step 3) is as follows: 301) Assume the label matrix S is composed of edges corresponding id value constitute: 302) If a node exists point to edge ,but: ; in: This represents the element in the k-th row of matrix S; 303) For all edges After performing the above operations, the label matrix S is rearranged, and the same labels are sorted out. Values ​​are marked using the smallest row number: ; The tag matrix S is rearranged into ascending order using a swap sorting algorithm. When swapping the m-th and n-th rows, the m-th and n-th rows and the m-th and n-th columns of the transaction graph matrix W and the transaction graph time matrix T are also swapped. After the adjustment, the adjacency matrix W and the adjacency matrix T will be transformed into a block diagonal matrix form. : The specific method for step 4) is as follows: 401) The random walk method was initially defined on a strongly connected and aperiodic directed graph G containing n nodes. Assuming graph G is unweighted, the transition matrix is: 402) If node The out-degree is k, and the node One of the incoming edges starts at node . Then the transition matrix The element in the i-th row and j-th column: Therefore, 403) Assume that the initial weights of all nodes in the random walk are equal, i.e. 404) Then the random walk model based on graph G can be expressed as: Then R is the final result of the random walk, i.e. in The weights of each node after the random walk are easily obtained as follows: in: Indicates pointing to The set of nodes, Represents a node The set of connected nodes; 405) From the construction of the transaction subgraph, it can be seen that the graph is not a strongly connected graph, that is, the columns of the transition matrix are 0. Therefore, the limit of the random walk is: 406) To avoid the case where the limit value does not exist, a damping factor d is defined empirically. If d is close to 1, the random walk mainly follows the transition matrix. If d is close to 0, the random walk visits any node in the graph with equal probability. The formula for calculating the result of the random walk is: Based on experience, the value d is usually taken as 0.85, which can avoid the problem that the limit of the random walk does not exist; The specific method for step 5) is as follows: 501) If we consider random walks in a weighted graph, the probability of a node walking is proportional to the weight of the outgoing edges. Assume a transaction subgraph. For a weighted graph, its adjacency matrix is: 502) The elements in the transition matrix are: in: Indicates by If we consider the change of the transition matrix over time for the set of nodes it points to, then a time coefficient needs to be introduced: 503) The formula for calculating the result of a random walk is: 504) In a graph neural network, suppose the features of node v are The features on edge (u, v) are The calculation is performed node-by-node and edge-by-edge according to the message passing paradigm: 505) is calculated from the above formula. and compute nodes and Link coefficients between : 506) Based on the link coefficient Define a loss function, using cross-entropy loss: in: Represents the Sigmoid function; 507) Determine whether the loss value exceeds the threshold. If it does not exceed the threshold, repeat steps 504)-507) to achieve transaction prediction.

2. The blockchain transaction behavior prediction method based on graph neural networks according to claim 1, characterized in that: The specific method for step 1) is as follows: Use Ethereum JSON RPC to obtain blockchain transaction data. First, a Go Ethereum connection is set up to connect to the blockchain mainnet. The blockchain's HTTP interface is implemented through Ethereum RPC configuration. Then, a web crawler is written to analyze the blockchain transaction data. Data acquisition, preprocessing, and storage are performed to obtain a blockchain transaction dataset. ; including blockchain transaction dataset The data structure includes: sequence number , Enter address Output address Transaction volume timestamp .

3. The blockchain transaction behavior prediction method based on graph neural networks according to claim 2, characterized in that: The specific method for step 2) is as follows: 201) Using the aforementioned blockchain transaction dataset , to enter address and output address As nodes, each blockchain data entry's transaction relationships form edges, using transaction amounts... and timestamp As weights, construct the input address Point to the output address Directed graph of blockchain transactions ; 202) Directed graph of blockchain transactions Extraction and preprocessing are performed: due to the transaction's input address and output address The 32-byte string format makes node name access difficult; therefore, a data dictionary is used to analyze the directed graph of blockchain transactions. Re-tagged; This process generates a blockchain transaction data dictionary. and the re-tagged blockchain transaction data table ; including the blockchain transaction data dictionary table Includes: number Transaction address ; Re-tagged blockchain transaction data table Includes: serial number , Enter address sequence number Output address sequence number Transaction volume timestamp Simultaneously, the blockchain transaction data table was re-tagged. Input address sequence number and output address sequence number The stored content is a blockchain transaction data dictionary table. number ; 203) In the re-tagged blockchain transaction data table Based on this, construct a blockchain transaction graph ;where the input address sequence number and output address sequence number Blockchain transaction diagram Nodes in and Constructing a system of nodes point to edge ,side The weight is ,side Time attribute Because a data dictionary is used to visualize the directed graph of blockchain transactions. Re-marking is performed, therefore reading The relabeled blockchain transaction graph, represented as a transaction graph matrix W: The element in its i-th row and j-th column is ,Right now Chinese representative of and representatives of Row number Simultaneously forming the transaction time matrix T: The element in the i-th row and j-th column is ; Simultaneously, the blockchain transaction diagram Includes: nodes ,node ,side weight of the edge The time attribute of the edge n represents the total number of nodes.

Citation Information

Patent Citations

  • Network platform based on regional chain and secure communication method thereof

    CN110874798A

  • Block chain abnormal transaction identification method and system based on unsupervised machine learning

    CN115187259A