+

CN116308372A - Detection method and device for blockchain transaction - Google Patents

Detection method and device for blockchain transaction Download PDF

Info

Publication number
CN116308372A
CN116308372A CN202211522132.1A CN202211522132A CN116308372A CN 116308372 A CN116308372 A CN 116308372A CN 202211522132 A CN202211522132 A CN 202211522132A CN 116308372 A CN116308372 A CN 116308372A
Authority
CN
China
Prior art keywords
target
resource
transaction
account
type
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211522132.1A
Other languages
Chinese (zh)
Inventor
周健飞
邬萌
王海军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ant Blockchain Technology Shanghai Co Ltd
Original Assignee
Ant Blockchain Technology Shanghai Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ant Blockchain Technology Shanghai Co Ltd filed Critical Ant Blockchain Technology Shanghai Co Ltd
Priority to CN202211522132.1A priority Critical patent/CN116308372A/en
Publication of CN116308372A publication Critical patent/CN116308372A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/40Authorisation, e.g. identification of payer or payee, verification of customer or shop credentials; Review and approval of payers, e.g. check credit lines or negative lists
    • G06Q20/401Transaction verification
    • G06Q20/4016Transaction verification involving fraud or risk level assessment in transaction processing

Landscapes

  • Business, Economics & Management (AREA)
  • Engineering & Computer Science (AREA)
  • Accounting & Taxation (AREA)
  • Computer Security & Cryptography (AREA)
  • Finance (AREA)
  • Strategic Management (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

本说明书实施例提供一种针对区块链交易的检测方法及装置。该方法包括:先获取区块链上目标交易的交易数据,该目标交易所调用目标智能合约的业务逻辑包括:从合约账户中转出第一数量的目标类数字资源发放至目标账户,以及,从目标账户中转出第二数量的目标类数字资源归还至合约账户;再从交易数据中解析出若干转账事件,其中每个转账事件包括转入方、转出方、数字资源类型,以及针对该类型的数字资源发生转账的数量;然后,根据若干转账事件确定目标账户针对各类数字资源的资源变化量,以及,获取各类数字资源在目标交易执行完成时的资源价值;再基于资源变化量和资源价值,确定目标交易为目标账户产生的价值变化量,用于判定目标交易的风险性。

Figure 202211522132

The embodiment of this specification provides a detection method and device for blockchain transactions. The method includes: first obtaining the transaction data of the target transaction on the blockchain, and the business logic of the target exchange calling the target smart contract includes: transferring the first quantity of target digital resources from the contract account to the target account, and, Transfer the second quantity of target digital resources from the target account and return them to the contract account; then analyze a number of transfer events from the transaction data, where each transfer event includes the transfer-in party, transfer-out party, digital resource type, and The number of transfers of this type of digital resources; then, according to several transfer events, determine the resource change amount of the target account for various digital resources, and obtain the resource value of various digital resources when the target transaction is completed; and then based on resource changes Quantity and resource value, determine the amount of value change generated by the target transaction for the target account, and use it to determine the risk of the target transaction.

Figure 202211522132

Description

针对区块链交易的检测方法及装置Detection method and device for blockchain transactions

技术领域technical field

本说明书实施例属于区块链技术领域,尤其涉及一种针对区块链交易的检测方法及装置。The embodiments of this specification belong to the technical field of blockchain, and in particular relate to a detection method and device for blockchain transactions.

背景技术Background technique

区块链(Blockchain)是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链系统中按照时间顺序将数据区块以顺序相连的方式组合成链式数据结构,并以密码学方式保证的不可篡改和不可伪造的分布式账本。由于区块链具有去中心化、信息不可篡改、自治性等特性,区块链也受到人们越来越多的重视和应用。Blockchain is a new application model of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. In the blockchain system, the data blocks are combined into a chained data structure in a sequentially connected manner in chronological order, and a non-tamperable and unforgeable distributed ledger is cryptographically guaranteed. Due to the characteristics of decentralization, non-tamperable information, and autonomy, the blockchain has also received more and more attention and application.

发明内容Contents of the invention

本发明的目的在于提供一种针对区块链交易的检测方法及装置,以高效识别出区块链交易中的风险交易,并向相关方提供预警。The purpose of the present invention is to provide a detection method and device for blockchain transactions, so as to efficiently identify risky transactions in blockchain transactions and provide early warnings to relevant parties.

本说明书第一方面提供一种针对区块链交易的检测方法。该方法包括:获取区块链上目标交易的交易数据,目标交易调用目标智能合约;目标智能合约的业务逻辑包括:合约账户中转出第一数量的目标类数字资源发放至目标账户,以及,从目标账户中转出第二数量的目标类数字资源归还至合约账户。从交易数据中解析出若干转账事件,其中每个转账事件包括转入方、转出方、数字资源类型,以及针对该类型的数字资源发生转账的数量。根据上述若干转账事件,确定目标账户针对各类数字资源的资源变化量。获取各类数字资源在目标交易执行完成时的资源价值。基于资源变化量和资源价值,确定目标交易为目标账户产生的价值变化量,用于判定目标交易的风险性。The first aspect of this specification provides a detection method for blockchain transactions. The method includes: obtaining the transaction data of the target transaction on the blockchain, and calling the target smart contract by the target transaction; the business logic of the target smart contract includes: transferring the first quantity of target digital resources from the contract account to the target account, and, The second quantity of target digital resources transferred from the target account is returned to the contract account. A number of transfer events are parsed from the transaction data, where each transfer event includes the transfer-in party, the transfer-out party, the type of digital resource, and the amount transferred for this type of digital resource. According to the above-mentioned several transfer events, determine the amount of resource change of the target account for various digital resources. Obtain the resource value of various digital resources when the execution of the target transaction is completed. Based on the amount of change in resources and the value of resources, determine the amount of change in value generated by the target transaction as the target account, and use it to determine the risk of the target transaction.

本说明书第二方面提供一种针对区块链交易的检测装置。该装置包括:交易数据获取模块,配置为获取区块链上目标交易的交易数据,目标交易调用目标智能合约;目标智能合约的业务逻辑包括:从合约账户中转出第一数量的目标类数字资源发放至目标账户,以及,从目标账户中转出第二数量的目标类数字资源归还至合约账户。转账事件确定模块,配置为从交易数据中解析出若干转账事件,其中每个转账事件包括转入方、转出方、数字资源类型,以及针对该类型的数字资源发生转账的数量。资源变化确定模块,配置为根据上述若干转账事件,确定目标账户针对各类数字资源的资源变化量。资源价值确定模块,配置为获取各类数字资源在目标交易执行完成时的资源价值。价值变化确定模块,配置为基于资源变化量和资源价值,确定目标交易为目标账户产生的价值变化量,用于判定目标交易的风险性。The second aspect of this specification provides a detection device for blockchain transactions. The device includes: a transaction data acquisition module configured to acquire transaction data of a target transaction on the block chain, and the target transaction calls the target smart contract; the business logic of the target smart contract includes: transferring the first amount of target digital from the contract account The resources are distributed to the target account, and the second quantity of target digital resources transferred from the target account is returned to the contract account. The transfer event determination module is configured to parse out several transfer events from the transaction data, where each transfer event includes the transfer-in party, transfer-out party, type of digital resource, and the amount of money transferred for this type of digital resource. The resource change determination module is configured to determine the resource change amount of the target account for various digital resources according to the above-mentioned several transfer events. The resource value determination module is configured to obtain the resource value of various digital resources when the execution of the target transaction is completed. The value change determination module is configured to determine the value change amount generated by the target transaction for the target account based on the resource change amount and the resource value, and is used to determine the risk of the target transaction.

本说明书第三方面提供一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行第一方面所述的方法。A third aspect of the present specification provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed in a computer, the computer is instructed to execute the method described in the first aspect.

本说明书第四方面提供一种计算设备,包括存储器和处理器,所述存储器中存储有可执行代码,所述处理器执行所述可执行代码时,实现第一方面所述的方法。A fourth aspect of the specification provides a computing device, including a memory and a processor, where executable codes are stored in the memory, and when the processor executes the executable codes, the method described in the first aspect is implemented.

在本说明书实施例提供的方案中,采用本说明书实施例披露的针对区块链交易的检测方法及装置,能够统计攻击者地址在交易前后针对各类数字资源的数量变化情况,结合针对每种数字资源确定出的实时资源价值、实时、自动地对区块链上调用目标智能合约的交易进行检测,并对该交易是否有套利风险进行评估。从而,可以实现对套利交易的及时预警,防止类似攻击的再次发生。In the solution provided by the embodiment of this specification, the detection method and device for blockchain transactions disclosed in the embodiment of this specification can be used to count the changes in the number of various digital resources of the attacker's address before and after the transaction. The real-time resource value determined by digital resources, real-time and automatic detection of the transaction that calls the target smart contract on the blockchain, and evaluates whether the transaction has arbitrage risk. Thus, timely early warning of arbitrage transactions can be realized to prevent recurrence of similar attacks.

附图说明Description of drawings

为了更清楚地说明本说明书实施例的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本说明书中记载的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions of the embodiments of this specification, the following will briefly introduce the drawings that need to be used in the description of the embodiments. Obviously, the drawings in the following description are only some embodiments recorded in this specification. , for those skilled in the art, other drawings can also be obtained according to these drawings without paying creative labor.

图1为一实施例中的区块链架构图;Fig. 1 is a blockchain architecture diagram in an embodiment;

图2为本说明书实施例中的一种针对区块链交易的检测方法的流程示意图;FIG. 2 is a schematic flow diagram of a detection method for blockchain transactions in an embodiment of this specification;

图3为本说明书实施例中的一种针对区块链交易的检测装置的结构示意图。FIG. 3 is a schematic structural diagram of a detection device for blockchain transactions in an embodiment of this specification.

具体实施方式Detailed ways

为了使本技术领域的人员更好地理解本说明书中的技术方案,下面将结合本说明书实施例中的附图,对本说明书实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本说明书一部分实施例,而不是全部的实施例。基于本说明书中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都应当属于本说明书保护的范围。In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described The embodiments are only some of the embodiments in this specification, not all of them. Based on the embodiments in this specification, all other embodiments obtained by persons of ordinary skill in the art without creative efforts shall fall within the protection scope of this specification.

下面先结合图1,对区块链技术中涉及的区块链架构、交易和智能合约等进行基本的介绍。In the following, combined with Figure 1, a basic introduction will be given to the blockchain architecture, transactions and smart contracts involved in blockchain technology.

图1示出了一实施例中的区块链架构图。在图1所示的区块链架构图中,区块链100中包括N个节点,图1中示意示出节点1-节点8。节点之间的连线示意性的表示P2P(Peer toPeer,点对点)连接,所述连接例如可以为TCP连接等,用于在节点之间传输数据。这些节点上可存储全量的账本,即存储全部区块和全部账户的状态。其中,区块链中的每个节点可通过执行相同的交易而产生区块链中的相同的状态,区块链中的每个节点可存储相同的状态数据库。Fig. 1 shows a block chain architecture diagram in an embodiment. In the blockchain architecture diagram shown in FIG. 1 , the blockchain 100 includes N nodes, and FIG. 1 schematically shows nodes 1 - 8 . The connection between the nodes schematically represents a P2P (Peer to Peer, point-to-point) connection, and the connection may be, for example, a TCP connection, etc., and is used to transmit data between the nodes. These nodes can store a full amount of books, that is, store the status of all blocks and all accounts. Wherein, each node in the blockchain can generate the same state in the blockchain by executing the same transaction, and each node in the blockchain can store the same state database.

区块链领域中的交易可以指在区块链中执行并记录在区块链中的任务单元。交易中通常包括发送字段(From)、接收字段(To)和数据字段(Data)。其中,在交易为转账交易的情况中,From字段表示发起该交易(即发起对另一个账户的转账任务)的账户地址,To字段表示接收该交易(即接收转账)的账户地址,Data字段中包括转账金额。A transaction in the blockchain field may refer to a unit of tasks performed and recorded in the blockchain. A transaction usually includes a sending field (From), a receiving field (To) and a data field (Data). Among them, when the transaction is a transfer transaction, the From field indicates the account address that initiated the transaction (that is, initiates a transfer task to another account), the To field indicates the account address that received the transaction (that is, received the transfer), and the Data field Include the transfer amount.

区块链中可提供智能合约的功能。区块链上的智能合约是在区块链系统上可以被交易触发执行的合约。智能合约可以通过代码的形式定义。在区块链中调用智能合约,是发起一笔指向智能合约地址的交易,使得区块链中每个节点分布式地运行智能合约代码。The function of smart contracts can be provided in the blockchain. Smart contracts on the blockchain are contracts that can be triggered by transactions on the blockchain system. Smart contracts can be defined in the form of code. Invoking a smart contract in the blockchain is to initiate a transaction pointing to the address of the smart contract, so that each node in the blockchain runs the smart contract code in a distributed manner.

在部署合约的场景中,例如,Bob将一个包含创建智能合约信息(即部署合约)的交易发送到如图1所示的区块链中,该交易的data字段包括待创建的合约的代码(如字节码或者机器码),交易的to字段为空,以表示该交易用于部署合约。节点间通过共识机制达成一致后,确定合约的合约地址“0x6f8ae93…”,各个节点在状态数据库中添加与该智能合约的合约地址对应的合约账户,分配与该合约账户对应的状态存储,并存储合约代码,将合约代码的哈希值保存在该合约的状态存储中,从而合约创建成功。In the scenario of deploying a contract, for example, Bob sends a transaction containing information about creating a smart contract (that is, deploying a contract) to the blockchain shown in Figure 1, and the data field of the transaction includes the code of the contract to be created ( Such as bytecode or machine code), the to field of the transaction is empty to indicate that the transaction is used to deploy the contract. After the nodes reach an agreement through the consensus mechanism, the contract address "0x6f8ae93..." is determined, each node adds the contract account corresponding to the contract address of the smart contract in the state database, allocates the state storage corresponding to the contract account, and stores Contract code, save the hash value of the contract code in the state storage of the contract, so that the contract is created successfully.

在调用合约的场景中,例如,Bob将一个用于调用智能合约的交易发送到如图1所示的区块链中,该交易的from字段是交易发起方(即Bob)的账户的地址,to字段为上述“0x6f8ae93…”,即被调用的智能合约的地址,交易的data字段包括调用智能合约的方法和参数。在区块链中对该交易进行共识之后,区块链中的各个节点可分别执行该交易,从而分别执行该合约,基于该合约的执行更新状态数据库。In the scenario of calling the contract, for example, Bob sends a transaction for calling the smart contract to the blockchain shown in Figure 1, the from field of the transaction is the address of the account of the transaction initiator (ie Bob), The to field is the above "0x6f8ae93...", which is the address of the called smart contract, and the data field of the transaction includes the method and parameters of calling the smart contract. After consensus is reached on the transaction in the blockchain, each node in the blockchain can respectively execute the transaction, thereby respectively executing the contract, and updating the state database based on the execution of the contract.

区块链技术区别于传统技术的去中心化特点之一,就是在各个节点上进行记账,或者称为分布式记账,而不是传统的集中式记账。区块链系统要成为一个难以攻破的、公开的、不可篡改数据记录的去中心化诚实可信系统,需要在尽可能短的时间内做到分布式数据记录的安全、明确及不可逆。不同类型的区块链网络中,为了在各个记录账本的节点中保持账本的一致,通常采用共识算法来保证,即前述提到的共识机制。例如,区块链节点之间可以实现区块粒度的共识机制,比如在节点(例如某个独特的节点)产生一个区块后,如果产生的这个区块得到其它节点的认可,其它节点记录相同的区块。再例如,区块链节点之间可以实现交易粒度的共识机制,比如在节点(例如某个独特的节点)获取一笔区块链交易后,如果这笔区块链交易得到其他节点的认可,认可该区块链交易的各个节点可以分别将该区块链交易添加至自身维护的最新区块中,并且最终能够确保各个节点产生相同的最新区块。共识机制是区块链节点就区块信息(或称区块数据)达成全网一致共识的机制,可以保证最新区块被准确添加至区块链。当前主流的共识机制包括:工作量证明(Proof ofWork,POW)、股权证明(Proof of Stake,POS)、委任权益证明(Delegated Proof of Stake,DPOS)、实用拜占庭容错(Practical Byzantine Fault Tolerance,PBFT)算法等。其中,在各种共识算法中,通常在预设数目的节点对待共识的数据(即共识提议)达成一致之后,从而确定对该共识提议的共识成功。具体是,在PBFT算法中,对于N≥3f+1个共识节点,可容忍f个恶意节点,也就是说,当N个共识节点中2f+1个节点达成一致时,可确定共识成功。One of the decentralized features of blockchain technology that distinguishes it from traditional technologies is that bookkeeping is performed on each node, or called distributed bookkeeping, rather than traditional centralized bookkeeping. In order for the blockchain system to become a decentralized, honest and credible system that is difficult to break, open, and cannot be tampered with data records, it is necessary to make distributed data records safe, clear, and irreversible in the shortest possible time. In different types of blockchain networks, in order to maintain the consistency of the ledger in each node that records the ledger, a consensus algorithm is usually used to ensure it, that is, the aforementioned consensus mechanism. For example, a block-granularity consensus mechanism can be implemented between blockchain nodes. For example, after a node (such as a unique node) generates a block, if the generated block is recognized by other nodes, other nodes record the same block. For another example, a consensus mechanism of transaction granularity can be implemented between blockchain nodes. For example, after a node (such as a unique node) obtains a blockchain transaction, if the blockchain transaction is recognized by other nodes, Each node that approves the blockchain transaction can add the blockchain transaction to the latest block maintained by itself, and finally can ensure that each node generates the same latest block. The consensus mechanism is a mechanism for blockchain nodes to reach a consensus on block information (or block data) in the entire network, which can ensure that the latest block is accurately added to the blockchain. The current mainstream consensus mechanisms include: Proof of Work (POW), Proof of Stake (POS), Delegated Proof of Stake (DPOS), Practical Byzantine Fault Tolerance (PBFT) algorithm etc. Among them, in various consensus algorithms, usually after a preset number of nodes reach an agreement on the data to be consensused (that is, the consensus proposal), it is determined that the consensus on the consensus proposal is successful. Specifically, in the PBFT algorithm, for N≥3f+1 consensus nodes, f malicious nodes can be tolerated, that is, when 2f+1 nodes among the N consensus nodes reach a consensus, the consensus can be determined to be successful.

以上,主要介绍区块链技术中的一些基本概念。The above mainly introduces some basic concepts in blockchain technology.

如前所述,区块链已经受到人们越来越多的重视和应用。举例来说,可以在区块链中开展数字资源(如电子票据等)的发布、转移、借贷等业务。在一种借贷业务场景中,服务方通过在区块链中部署智能合约向用户提供数字资源的借贷服务;用户通过使用借贷服务,可以借出大笔的数字资源,前提是需要保证在一笔交易内完成数字资源的借出和归还。有些攻击者会使用从借贷服务中借出的大笔数字资源,在短时间对不同种数字资源进行买入、卖出等操作,以操控不同数字资源的汇率,从而套取高额利益。当攻击者发现其攻击成功以后,通常会再次进行类似攻击。目前,对于这类以套利为目的的风险交易,主要依赖人工分析进行检测,导致工作量大、成本高、实时性差。As mentioned earlier, blockchain has received more and more attention and application. For example, the issuance, transfer, lending and other services of digital resources (such as electronic bills, etc.) can be carried out in the blockchain. In a lending business scenario, the service provider provides users with digital resource lending services by deploying smart contracts in the blockchain; The lending and returning of digital resources is completed within the transaction. Some attackers will use a large amount of digital resources lent from lending services to buy and sell different digital resources in a short period of time to manipulate the exchange rates of different digital resources, thereby arbitrating high profits. When the attacker finds that his attack is successful, he usually conducts a similar attack again. At present, for such risky transactions for the purpose of arbitrage, it mainly relies on manual analysis for detection, resulting in heavy workload, high cost, and poor real-time performance.

基于以上观察和分析,本说明书实施例披露一种针对区块链交易的检测方案,可以自动、高效地检测出以套利为目的的风险交易。Based on the above observation and analysis, the embodiment of this specification discloses a detection scheme for blockchain transactions, which can automatically and efficiently detect risky transactions for the purpose of arbitrage.

图2为本说明书实施例中的一种针对区块链交易的检测方法的流程示意图,所述方法的执行主体可以为任何具有计算、处理能力的装置、平台、服务器或设备集群等。示例性的,用于实现该方法的功能代码可以部署在区块链以外的其他设备中,或者,也可以部署在区块链节点中,例如,可以部署在区块链全节点上。Fig. 2 is a schematic flow diagram of a detection method for blockchain transactions in the embodiment of this specification, and the subject of execution of the method may be any device, platform, server or device cluster with computing and processing capabilities. Exemplarily, the functional code for implementing the method can be deployed in other devices than the blockchain, or can also be deployed in the blockchain nodes, for example, can be deployed on the full nodes of the blockchain.

如图2所示,所述方法包括以下步骤:As shown in Figure 2, the method includes the following steps:

步骤S210,获取区块链上目标交易的交易数据,该目标交易调用目标智能合约。该目标智能合约的业务逻辑包括:从该目标智能合约的合约账户中转出第一数量的目标类数字资源发放至目标账户,以及,从目标账户中转出第二数量的目标类数字资源归还至该合约账户。Step S210, acquiring the transaction data of the target transaction on the block chain, and the target transaction invokes the target smart contract. The business logic of the target smart contract includes: transferring the first quantity of target digital resources from the contract account of the target smart contract to the target account, and transferring the second quantity of target digital resources from the target account to return to the contract account.

可以理解,上述服务方可以通过在区块链中部署上述目标智能合约提供借贷服务。目标类数字资源是指目标智能合约针对的一类数字资源,区分于区块链上流通的其他类数字资源。上述目标账户为区块链账户,可以是外部账户,也可以是合约账户。It can be understood that the above-mentioned service party can provide lending services by deploying the above-mentioned target smart contract in the blockchain. The target digital resource refers to a type of digital resource targeted by the target smart contract, which is different from other types of digital resources circulating on the blockchain. The above target account is a blockchain account, which can be an external account or a contract account.

上述目标智能合约的传入参数至少包括上述目标账户和第一数量。在一个实施例中,上述第二数量可以由目标智能合约基于第一数量,根据预先设定的本息(本金+利息)计算方式而自动计算得到,通常,第二数量大于第一数量。在另一个实施例中,目标智能合约的传入参数还包括上述第二数量,此时,目标智能合约的业务逻辑还可以包括:在判断出第二数量与第一数量的比值大于预设比例阈值的情况下,向目标账户发放第一数量的目标类数字资源。The incoming parameters of the above-mentioned target smart contract include at least the above-mentioned target account and the first quantity. In one embodiment, the above-mentioned second amount can be automatically calculated by the target smart contract based on the first amount and according to a preset calculation method of principal and interest (principal + interest). Usually, the second amount is greater than the first amount. In another embodiment, the incoming parameters of the target smart contract also include the above-mentioned second quantity. At this time, the business logic of the target smart contract may also include: after judging that the ratio of the second quantity to the first quantity is greater than the preset ratio In the case of the threshold value, the first quantity of target digital resources is issued to the target account.

在一个实施例中,上述目标交易还调用除目标智能合约以外的若干智能合约,例如,调用用于提供不同种数字资源之间兑换、买卖服务的智能合约。需理解,文中的若干指代一个或多个。In one embodiment, the above-mentioned target transaction also calls several smart contracts other than the target smart contract, for example, calls a smart contract for providing exchange and trading services between different kinds of digital resources. It should be understood that a number herein refers to one or more.

在一个具体的实施例中,若干智能合约包括针对两类数字资源的第一智能合约,该第一智能合约的业务逻辑包括:第一智能合约的第一合约账户接收从第一账户转出的第三数量的第一类数字资源,并且,从第一合约账户向第一账户转入第四数量的第二类数字资源。可以理解,第一账户可以是外部账户或智能合约账户。在一个例子中,第一智能合约的部署基于第二智能合约,第二智能合约中建立上述两类数字资源之间的可交易关系,由此,该两类数字资源形成交易资源对。In a specific embodiment, several smart contracts include a first smart contract for two types of digital resources, and the business logic of the first smart contract includes: the first contract account of the first smart contract receives the transfer from the first account A third quantity of the first type of digital resource, and a fourth quantity of the second type of digital resource is transferred from the first contract account to the first account. It can be understood that the first account may be an external account or a smart contract account. In one example, the deployment of the first smart contract is based on the second smart contract, and the tradable relationship between the above two types of digital resources is established in the second smart contract, so that the two types of digital resources form a trading resource pair.

上述第一智能合约的传入参数可以包括上述第一账户和第三数量,上述第四数量可以由第一智能合约根据上述两类数字资源之间的实时汇率对第三数量进行换算而得到。在一个示例中,第一账户与上述目标账户被传入相同的账户地址。在一个示例中,上述第一类数字资源为目标类数字资源。The incoming parameters of the first smart contract may include the first account and the third quantity, and the fourth quantity may be obtained by converting the third quantity by the first smart contract according to the real-time exchange rate between the two types of digital resources. In one example, the first account and the above-mentioned target account are transferred to the same account address. In an example, the above-mentioned first type of digital resource is a target type of digital resource.

以上对目标交易可能涉及的合约调用进行介绍。The contract calls that may be involved in the target transaction are introduced above.

在本步骤的执行过程中,可以先从区块链网络中获取多个交易的交易数据。During the execution of this step, the transaction data of multiple transactions can be obtained from the blockchain network first.

在一个实施例中,该多个交易包括区块链中存储的交易,也即,被打包上链的交易。在另一个实施例中,该多个交易包括实时搜集的在区块链网络中广播的交易。需理解,对于新挖掘出的区块,任一的区块链节点在验证出其合法后会在区块链网络中对其进行广播,基于此,可以实时监听广播的区块,从而获取该区块上的交易。示例性的,可以通过区块链全节点实时监测区块链中的新增交易,从而及时识别出风险交易。In one embodiment, the multiple transactions include transactions stored in the blockchain, that is, transactions packaged on the blockchain. In another embodiment, the plurality of transactions includes transactions broadcast in the blockchain network collected in real time. It should be understood that for newly mined blocks, any blockchain node will broadcast them in the blockchain network after verifying that they are legal. Based on this, the broadcasted blocks can be monitored in real time to obtain the transactions on the block. Exemplarily, the new transactions in the blockchain can be monitored in real time through the full nodes of the blockchain, so as to identify risky transactions in a timely manner.

在一个实施例中,交易数据可以包括各个交易的交易体,和/或,交易日志。在一个具体的实施例中,交易数据中包括交易哈希、区块号、交易发起者和接收者的地址、交易的输入参数(如data字段)、交易的执行结果、以及交易中调用智能合约而触发的内部交易的内部交易数据,内部交易数据包括内部交易调用者和接收者的地址,以及内部交易的输入参数(如data字段)。In one embodiment, transaction data may include a transaction body for each transaction, and/or a transaction log. In a specific embodiment, the transaction data includes the transaction hash, the block number, the address of the transaction initiator and receiver, the input parameters of the transaction (such as the data field), the execution result of the transaction, and the smart contract called in the transaction As for the internal transaction data of the triggered internal transaction, the internal transaction data includes the addresses of the caller and receiver of the internal transaction, and the input parameters of the internal transaction (such as the data field).

基于以上获取的多个交易的交易数据,可以从该多个交易中筛选出目标交易。Based on the transaction data of multiple transactions acquired above, target transactions can be selected from the multiple transactions.

在一个实施例中,可以直接从多个交易中筛选出调用了预先设定的目标函数的若干交易,再将该若干交易分别作为目标交易。其中目标函数用于实现目标智能合约的业务逻辑。需要理解,目标智能合约中包括多个函数,可以从中选取具有区分度的、与借贷服务强相关的一个或一组函数,作为上述预先设定的目标函数。In one embodiment, several transactions that call a preset target function can be directly screened out from multiple transactions, and then these several transactions are respectively used as target transactions. The target function is used to implement the business logic of the target smart contract. It needs to be understood that the target smart contract includes multiple functions, from which one or a group of functions that are differentiated and strongly related to lending services can be selected as the above-mentioned preset target function.

具体地,交易数据中包括对应交易中调用智能合约的方法和参数,由此,可以基于预先设定的目标函数,分别匹配多个交易中各个交易的交易数据,从而得到匹配成功的若干交易。Specifically, the transaction data includes the method and parameters of calling the smart contract in the corresponding transaction. Therefore, based on the preset objective function, the transaction data of each transaction in multiple transactions can be matched respectively, so as to obtain several transactions that are successfully matched.

在另一个实施例中,还可以先对多个交易进行预筛选,再根据预筛选的结果确定上述若干交易,从而提高本步骤的执行效率。In another embodiment, multiple transactions may be pre-screened first, and then the above-mentioned several transactions may be determined according to the results of the pre-screening, thereby improving the execution efficiency of this step.

在一个具体的实施例中,预筛选可以包括:滤除交易日志长度低于预设长度阈值的交易。示例性的,交易日志的长度可以利用字符数或占用的存储空间进行度量。In a specific embodiment, the pre-screening may include: filtering out transactions whose transaction log length is lower than a preset length threshold. Exemplarily, the length of the transaction log can be measured by the number of characters or the occupied storage space.

在另一个具体的实施例中,预筛选可以包括:滤除涉及的转账类事件个数小于预设个数阈值的交易。对于其中转账类事件个数的确定,在一个示例中,交易数据中包括交易日志,交易日志中记录解析出的事件,具体记录事件类型等事件参数,此时,可以针对各个交易分别确定其交易日志中转账类事件的个数;在另一个示例中,交易数据中包括交易体,此时,可以利用部署在区块链节点上的虚拟机(Virtual Machine,简称VM)执行各个交易的交易体,从而确定各个交易涉及的转账类事件个数。In another specific embodiment, the pre-screening may include: filtering out transactions involving transfer events whose number is less than a preset number threshold. For the determination of the number of transfer events, in an example, the transaction data includes a transaction log, which records the parsed events, and specifically records event parameters such as event types. At this time, the transaction can be determined for each transaction The number of transfer events in the log; in another example, the transaction data includes the transaction body. At this time, the virtual machine (Virtual Machine, VM for short) deployed on the blockchain node can be used to execute the transaction body of each transaction , so as to determine the number of transfer events involved in each transaction.

在又一个具体的实施例中,预筛选可以包括:滤除输入参数为空的交易。In yet another specific embodiment, the pre-screening may include: filtering out transactions whose input parameters are empty.

通过上述预筛选操作,可以从多个交易中排除不可能调用了目标智能合约的交易。进一步,可以基于被保留下来的交易,筛选出上述调用了上述预设目标函数的若干交易,从而将该若干交易中的各个交易分别作为目标交易。Through the above-mentioned pre-screening operation, transactions that are unlikely to call the target smart contract can be excluded from multiple transactions. Further, based on the retained transactions, the above-mentioned several transactions that invoke the above-mentioned preset target function can be screened out, so that each of the several transactions can be used as the target transaction respectively.

基于以上获取的目标交易,可以执行步骤S220,从目标交易的交易数据中解析出若干转账事件,其中每个转账事件包括转入方、转出方、数字资源类型,以及针对该类型的数字资源发生转账的数量。Based on the target transaction obtained above, step S220 can be executed to analyze a number of transfer events from the transaction data of the target transaction, where each transfer event includes the transfer-in party, transfer-out party, digital resource type, and digital resource for this type The amount of transfers that occurred.

在一个实施例中,可以从目标交易的交易数据(以下或简称目标交易数据)中解析出所有的转账类事件,作为上述若干转账事件。在一个具体的实施例中,目标交易数据中包括记录区块链事件的交易日志,由此,可以从交易日志中解析出所有事件类型为转账的事件,归为上述若干转账事件。在另一个具体的实施例中,目标交易数据中包括交易体,此时,可以利用区块链节点上部署的VM执行交易体,从而通过解析执行结果得到上述若干转账事件。In one embodiment, all transfer events can be parsed from the transaction data of the target transaction (hereinafter referred to as the target transaction data) as the above-mentioned several transfer events. In a specific embodiment, the target transaction data includes a transaction log that records blockchain events, so all events whose event type is transfer can be parsed from the transaction log and classified into the above-mentioned several transfer events. In another specific embodiment, the target transaction data includes the transaction body. At this time, the VM deployed on the blockchain node can be used to execute the transaction body, so as to obtain the above-mentioned several transfer events by analyzing the execution result.

不妨将每个转账事件都组织为四元组E<Type ID,From,To,Tdelta>的形式,其中Type ID表示数字资源类型的标识,比如说,可以是管理(如发行)该类数字资源的智能合约的标识,通常为该智能合约的合约地址(Contract Address);From表示转账事件的转出方,或者说转账发送者;To表示转账事件的转入方,或者说转账接收者;Tdelta表示数字资源的转账数量。It is advisable to organize each transfer event into the form of a quadruple E<Type ID, From, To, T delta >, where Type ID represents the identification of the type of digital resource, for example, it can be used to manage (such as issue) such digital resources The identifier of the smart contract of the resource, usually the contract address of the smart contract (Contract Address); From means the transferer of the transfer event, or the sender of the transfer; To means the transferer of the transfer event, or the transfer receiver; T delta represents the transfer amount of digital resources.

进一步,在一个示例中,本步骤中解析出的若干转账事件可以包括:Further, in an example, several transfer events analyzed in this step may include:

E1:<类型1,CA,TA,10000>E1: <Type 1, CA, TA, 10000>

E2:<类型1,TA,BA,9000>E2: <Type 1, TA, BA, 9000>

E3:<类型2,BA,TA,3000>E3: <Type 2, BA, TA, 3000>

E4:<类型2,TA,BA,2500>E4: <Type 2, TA, BA, 2500>

E5:<类型1,BA,TA,10000>E5: <Type 1, BA, TA, 10000>

E6:<类型1,TA,CA,10050>E6: <Type 1, TA, CA, 10050>

在上示7个转账事件E1至E6中,CA表示目标智能合约的合约账户地址,TA表示目标账户的账户地址,BA表示提供针对类型1和类型2的数字资源兑换服务的智能合约的合约账户地址。观察事件E1和E6,TA向CA借到10000份类型1的数字资源,并归还10050份类型1的数字资源;观察事件E2和E3,TA用9000份类型1的数字资源向BA兑换3000份类型2的数字资源;观察事件E4和E5,TA用2500份类型2的数字资源向BA兑换10000份类型1的数字资源。In the above seven transfer events E1 to E6, CA represents the contract account address of the target smart contract, TA represents the account address of the target account, and BA represents the contract account of the smart contract that provides digital resource exchange services for Type 1 and Type 2 address. Observe events E1 and E6, TA borrows 10,000 copies of type 1 digital resources from CA, and returns 10,050 copies of type 1 digital resources; observe events E2 and E3, TA exchanges 9,000 copies of type 1 digital resources with BA for 3,000 copies of type 2 digital resources; observe events E4 and E5, TA exchanges 2500 type 2 digital resources with BA for 10000 type 1 digital resources.

在另一个实施例中,可以先从目标交易数据中解析出所有的转账类事件,再将其中转入方或转出方为上述目标账户的转账事件归为若干转账事件。In another embodiment, all transfer events can be parsed from the target transaction data first, and then the transfer events in which the transfer-in or transfer-out party is the above-mentioned target account can be classified into several transfer events.

由上,可以确定出目标交易涉及的若干转账事件。然后,可以执行步骤S230,根据该若干转账事件,确定目标账户针对各类数字资源的资源变化量。Based on the above, several transfer events involved in the target transaction can be determined. Then, step S230 may be executed to determine the amount of resource change of the target account for various types of digital resources according to the several transfer events.

上述若干转账事件涉及多类数字资源,通过对若干转账事件进行统计分析,可以得到目标账户针对该多类数字资源中各类数字资源的资源变化量。示例性的,对上示事件E1至事件E6进行统计分析,可以确定出目标账户TA针对类型1和类型2的数字资源的变化量分别为:+950和+500。The above-mentioned several transfer events involve multiple types of digital resources. Through statistical analysis of several transfer events, the amount of resource change of the target account for each type of digital resources among the multiple types of digital resources can be obtained. Exemplarily, statistical analysis is performed on the events E1 to E6 above, and it can be determined that the amount of change of the target account TA for digital resources of type 1 and type 2 is +950 and +500, respectively.

另一方面,执行步骤S240,获取各类数字资源在目标交易执行完成时的资源价值。具体地,可以将上述多类数字资源分别换算为预定义的等价物,从而实现价值的统一度量。需要理解,等价物通常可被定义为任意一种可度量的物品。示例性的,等价物可以是预先设定的某类型数字资源。On the other hand, step S240 is executed to obtain resource values of various digital resources when the target transaction is executed. Specifically, the above-mentioned multiple types of digital resources can be converted into predefined equivalents, so as to achieve a unified measurement of value. It should be understood that an equivalent can generally be defined as any kind of measurable item. Exemplarily, the equivalent may be a preset digital resource of a certain type.

在一个实施例中,多类数字资源中包括单位价值动态变化的第三类数字资源,由此,可以先确定第三类数字资源和具有预设价值的第四类数字资源之间的汇率,再根据此汇率和该预设价值,确定第三类数字资源在执行目标交易后的实时价值。In one embodiment, the multiple types of digital resources include a third type of digital resource whose unit value dynamically changes, so that the exchange rate between the third type of digital resource and the fourth type of digital resource with a preset value can be determined first, Then, according to the exchange rate and the preset value, determine the real-time value of the third type of digital resource after executing the target transaction.

对于上述汇率的确定,在一个具体的实施例中,可以先确定执行目标交易后,第三类数字资源和第四类数字资源各自在对应资源池中的资源数量,再基于此资源数量确定出二者之间的汇率。在一个更具体的实施例中,可以根据目标交易数据,以及发生在目标交易之前的其他交易的交易数据,确定与这两类数字资源相关的数字资源数量的更新事件,从而确定资源池中的资源数量。For the determination of the above-mentioned exchange rate, in a specific embodiment, after the execution of the target transaction, the resource quantities of the third type of digital resources and the fourth type of digital resources in the corresponding resource pools can be determined first, and then determined based on the amount of resources exchange rate between the two. In a more specific embodiment, according to the target transaction data and the transaction data of other transactions that occurred before the target transaction, the update event of the number of digital resources related to these two types of digital resources can be determined, so as to determine the number of digital resources in the resource pool. number of resources.

在另一个更具体的实施例中,可以通过区块链浏览器的查询功能,建立多个知名服务方与区块链中用于管理多类数字资源的多个智能合约之间的映射关系。从而,先从区块链存储的多个交易中过滤出与该知名服务方发生交互的交易,再对过滤出的交易的数据进行分析,解析出数字资源的数量发生更新的事件,进而确定第三类数字资源和第四类数字资源各自在资源池中的资源数量。In another more specific embodiment, the mapping relationship between multiple well-known service parties and multiple smart contracts used to manage multiple types of digital resources in the blockchain can be established through the query function of the blockchain browser. Therefore, first filter out the transactions that interact with the well-known service provider from the multiple transactions stored in the blockchain, and then analyze the data of the filtered transactions to analyze the event that the number of digital resources is updated, and then determine the first The respective resource quantities of the third type of digital resources and the fourth type of digital resources in the resource pool.

进一步,可以将上述确定出的两个资源数量,代入针对上述第三类和第四类数字资源预先设定的汇率计算公式中,得到二者之间的汇率。Furthermore, the above-mentioned determined quantities of the two resources may be substituted into the preset exchange rate calculation formulas for the above-mentioned third and fourth types of digital resources to obtain the exchange rate between the two.

基于得到的汇率,可以先确定将单位数量的第三类数字资源换算为第四类数字资源时的数量,再根据此数量和第四类数字资源具有的预设价值,确定第三类数字资源的资源价值。Based on the obtained exchange rate, it is possible to first determine the quantity when the unit quantity of the third type of digital resource is converted into the fourth type of digital resource, and then determine the third type of digital resource based on this quantity and the preset value of the fourth type of digital resource resource value.

在另一个实施例中,多类数字资源中包括具有预设单位价值的第四类数字资源,此时,可以直接将该预设单位价值确定为第四类数字资源的资源价值。In another embodiment, the multiple types of digital resources include a fourth type of digital resource with a preset unit value. At this time, the preset unit value can be directly determined as the resource value of the fourth type of digital resource.

由上,可以确定出各类数字资源的资源变化量,以及各类数字资源在目标交易执行后的资源价值。之后,执行步骤S250,基于该资源变化量和资源价值,确定目标交易为目标账户产生的价值变化量,用于判断目标交易的风险性。Based on the above, the amount of resource change of various digital resources and the resource value of various digital resources after the execution of the target transaction can be determined. Afterwards, step S250 is executed, based on the resource change amount and resource value, the value change amount generated by the target transaction for the target account is determined, which is used to judge the risk of the target transaction.

在一个实施例中,针对目标交易中涉及的各类资源,可以先计算其对应的资源变化量和资源价值之间的乘积,再求取计算出的乘积之间的和值,作为上述价值变化量。In one embodiment, for all kinds of resources involved in the target transaction, the product of the corresponding resource change and resource value can be calculated first, and then the sum of the calculated products can be calculated as the value change quantity.

示例性地,假定目标交易中涉及类型1和类型2的数字资源,类型1对应的资源变化量和资源价值分别为+950和1,类型2对应的资源变化量和资源价值分别为+500和2,此时,可以计算出价值变化量为1950。Exemplarily, assuming that digital resources of type 1 and type 2 are involved in the target transaction, the resource change amount and resource value corresponding to type 1 are +950 and 1 respectively, and the resource change amount and resource value corresponding to type 2 are +500 and resource value respectively 2. At this point, the value change can be calculated as 1950.

在另一个实施例中,考虑到在执行目标交易之前,目标账户中可能已经存在一些数字资源,为简洁描述,以下将之称为初始数字资源,示例性的,初始数字资源可以通过查询或追踪该目标账户涉及的转账事件等方式获取。此时,在计算上述价值变化量时,还可以考虑目标交易的执行为初始数字资源带来的价值变化,具体,可以考虑初始数字资源中与目标交易涉及的数字资源具有相同类型的部分。In another embodiment, considering that some digital resources may already exist in the target account before executing the target transaction, for the sake of brevity, they are referred to as initial digital resources hereinafter. Exemplarily, the initial digital resources can be tracked or tracked The transfer event involved in the target account can be obtained by other means. At this time, when calculating the above-mentioned value change, the value change brought by the execution of the target transaction to the initial digital resource can also be considered. Specifically, the part of the initial digital resource that has the same type as the digital resource involved in the target transaction can be considered.

在一个具体的实施例中,针对由上述相同类型形成的类型交集中的各个类型,还确定其在执行目标交易之前的初始价值,再利用该类型在目标交易执行完成时的资源价值减去初始价值,从而利用得到的差值乘以该类型在初始数字资源中的数量,得到执行目标交易为初始数字资源中具有该类型的数字资源部分带来的价值变化分量。需理解,其中初始价值的确定方式可以参考前述针对资源价值的确定方式,不作赘述。In a specific embodiment, for each type in the type intersection formed by the above-mentioned same type, its initial value before executing the target transaction is also determined, and then the resource value of the type when the target transaction is executed is completed minus the initial value, so that the obtained difference is multiplied by the quantity of this type in the initial digital resources to obtain the value change component brought by the execution of the target transaction to the digital resources of this type in the initial digital resources. It should be understood that the method for determining the initial value can refer to the method for determining the resource value mentioned above, and details are not repeated here.

进一步,对类型交集中各个类型对应的价值变化分量进行求和,可以得到执行目标交易为目标账户中的初始资源产生的第一价值变化量,再在此基础上叠加执行目标交易给目标账户带来的资源变化量所产生的第二价值变化量,可以得到执行目标交易为目标账户带来的价值变化量(或称价值变化总量)。Further, by summing the value change components corresponding to each type in the type intersection, the first value change amount generated by executing the target transaction as the initial resource in the target account can be obtained, and then superimposed on this basis to execute the target transaction to bring the target account. The second value change amount generated by the resource change amount from the source can obtain the value change amount (or total value change amount) brought to the target account by executing the target transaction.

在另一个例子中,基于上述初始数字资源和上述资源变化量,可以确定在执行目标交易之前和之后,目标账户针对各类数字资源先后具有的数量,然后,根据各个类型的数字资源在目标交易执行前后的价值,确定执行目标交易为目标账户带来的价值变化量。In another example, based on the above-mentioned initial digital resources and the above-mentioned resource changes, it is possible to determine the number of various digital resources in the target account before and after executing the target transaction, and then, according to each type of digital resources in the target transaction The value before and after execution determines the amount of value change brought by the execution of the target transaction to the target account.

由上,可以确定出执行目标交易为目标账户带来的价值变化量。Based on the above, it is possible to determine the amount of value change brought by the execution of the target transaction to the target account.

根据另一方面的实施例,考虑到存在攻击者为了避免其发起的套利交易被监测到,而将目标账户中的获利转移到其他账户的情况。在上述步骤S230中,在确定资源变化量时,确定的可以是目标账户和发起目标交易的发起账户共同针对各类数字资源的变化量。示例性的,从目标交易的交易数据中除了确定中出上述事件E1-E6以外,还确定出以下事件E7-E8:According to another embodiment, it is considered that in order to avoid the arbitrage transaction initiated by the attacker from being detected, the attacker transfers the profit in the target account to other accounts. In the above step S230, when determining the amount of change in resources, what is determined may be the amount of change in various types of digital resources jointly by the target account and the initiating account that initiates the target transaction. Exemplarily, in addition to the above-mentioned events E1-E6, the following events E7-E8 are also determined from the transaction data of the target transaction:

E7:<类型1,TA,FA,950>E7: <Type 1, TA, FA, 950>

E8:<类型2,TA,FA,500>E8: <Type 2, TA, FA, 500>

此时,如果仅确定目标账户的资源变化量,则确定出的对应类型1和类型2的会是0和0,但是若确定的是针对目标账户和发起方账户FA的资源变化量,则确定出的仍是950和500。At this time, if only the resource change of the target account is determined, the determined corresponding type 1 and type 2 will be 0 and 0, but if the resource change of the target account and the initiator account FA is determined, then determine 950 and 500 are still out.

相应,在步骤S250中,确定出的价值变化量是同时针对目标账户和发起账户的。Correspondingly, in step S250, the determined value variation is for both the target account and the initiating account.

根据又一方面的实施例,在执行步骤S250之后,上述方法还可以包括:判断价值变化量是否大于预设增量阈值,从而在判断出大于的情况下,判定目标交易为风险交易,否则判定为正常交易。进一步,在判定出目标交易为风险交易的情况下,可以对目标交易中所调用智能合约的合约创建方进行预警,以提醒其及时进行漏洞修复,避免同类攻击的再次发生。或者,在执行步骤S250之后,还可以将价值变化量作为风险分数,作为风险性参考。According to yet another embodiment, after step S250 is performed, the above method may further include: judging whether the value change is greater than a preset increment threshold, so that if it is judged to be greater than the value, it is judged that the target transaction is a risk transaction, otherwise it is judged for normal transactions. Furthermore, when the target transaction is determined to be a risky transaction, an early warning can be given to the contract creator of the smart contract called in the target transaction to remind it to repair the vulnerability in time to avoid the recurrence of similar attacks. Alternatively, after step S250 is performed, the amount of value change may also be used as a risk score, as a risk reference.

由上,可以实现自动识别出区块链中包含的以套利为目的的风险交易。From the above, it is possible to automatically identify risky transactions for arbitrage purposes contained in the blockchain.

综上,采用本说明书实施例披露的针对区块链交易的检测方法,能够统计攻击者地址在交易前后针对各类数字资源的数量变化情况,结合针对每种数字资源确定出的实时资源价值、实时、自动地对区块链上调用目标智能合约的交易进行检测,并对该交易是否有套利风险进行评估。从而,可以实现对套利交易的及时预警,防止类似攻击的再次发生。In summary, using the detection method for blockchain transactions disclosed in the embodiments of this specification, it is possible to count the changes in the number of various digital resources of the attacker’s address before and after the transaction, combined with the real-time resource value determined for each digital resource, Real-time and automatic detection of the transaction calling the target smart contract on the blockchain, and evaluate whether the transaction has arbitrage risk. Thus, timely early warning of arbitrage transactions can be realized to prevent recurrence of similar attacks.

与上述检测方法相对应的,本说明书实施例还披露检测装置。图3为本说明书实施例中的一种针对区块链交易的检测装置的结构示意图,如图3所示,装置300包括以下组成模块:Corresponding to the above detection method, the embodiment of this specification also discloses a detection device. Fig. 3 is a schematic structural diagram of a detection device for blockchain transactions in the embodiment of this specification. As shown in Fig. 3, the device 300 includes the following components:

交易数据获取模块310,配置为获取区块链上目标交易的交易数据,目标交易调用目标智能合约;目标智能合约的业务逻辑包括:从合约账户中转出第一数量的目标类数字资源发放至目标账户,以及,从目标账户中转出第二数量的目标类数字资源归还至合约账户。转账事件确定模块320,配置为从交易数据中解析出若干转账事件,其中每个转账事件包括转入方、转出方、数字资源类型,以及针对该类型的数字资源发生转账的数量。资源变化确定模块330,配置为根据上述若干转账事件,确定目标账户针对各类数字资源的资源变化量。资源价值确定模块340,配置为获取各类数字资源在目标交易执行完成时的资源价值。价值变化确定模块350,配置为基于资源变化量和资源价值,确定目标交易为目标账户产生的价值变化量,用于判定目标交易的风险性。The transaction data acquisition module 310 is configured to obtain the transaction data of the target transaction on the block chain, and the target transaction calls the target smart contract; the business logic of the target smart contract includes: transferring the first quantity of target digital resources from the contract account and issuing them to The target account, and the second quantity of target digital resources transferred from the target account and returned to the contract account. The transfer event determination module 320 is configured to parse out several transfer events from the transaction data, where each transfer event includes the transfer-in party, transfer-out party, type of digital resource, and the amount transferred for this type of digital resource. The resource change determination module 330 is configured to determine the resource change amount of the target account for various digital resources according to the above-mentioned several transfer events. The resource value determination module 340 is configured to obtain the resource value of various digital resources when the execution of the target transaction is completed. The value change determination module 350 is configured to determine the value change amount generated by the target transaction for the target account based on the resource change amount and the resource value, for determining the risk of the target transaction.

在一个实施例中,交易数据包括以下至少一项:交易体、交易日志,交易日志中包括若干转账事件。In one embodiment, the transaction data includes at least one of the following: a transaction body, a transaction log, and the transaction log includes several transfer events.

在一个实施例中,交易数据获取模块310具体包括:数据获取单元311,配置为获取区块链中存储的多个交易的交易数据;交易筛选单元312,配置为基于多个交易的交易数据,筛选出调用预先设定的目标函数的若干交易;目标函数用于实现业务逻辑;将若干交易中的每个交易分别作为目标交易。In one embodiment, the transaction data acquisition module 310 specifically includes: a data acquisition unit 311 configured to acquire transaction data of multiple transactions stored in the block chain; a transaction screening unit 312 configured to, based on the transaction data of multiple transactions, Screen out several transactions that call a preset target function; the target function is used to implement business logic; and each of the multiple transactions is used as a target transaction.

在一个具体的实施例中,交易筛选单元312具体配置为:从多个交易中去除交易数据涉及的转账事件个数小于预设个数阈值的交易;基于剩余交易的交易数据,从该剩余交易中筛选出若干交易。In a specific embodiment, the transaction screening unit 312 is specifically configured to: remove transactions whose number of transfer events involved in the transaction data is less than a preset number threshold from multiple transactions; based on the transaction data of the remaining transactions, from the remaining transactions Filter out a few transactions.

在一个实施例中,目标交易还调用其他的若干智能合约,其中包括的第一智能合约用于提供不同类型的数字资源之间的兑换服务。In one embodiment, the target transaction also invokes several other smart contracts, the first smart contract included is used to provide exchange services between different types of digital resources.

在一个具体的实施例中,第一智能合约的业务逻辑包括:第一合约账户接收从第一账户转出的第三数量的第一类数字资源,并且,从第一合约账户向第一账户转入第四数量的第二类数字资源。In a specific embodiment, the business logic of the first smart contract includes: the first contract account receives the third amount of the first type of digital resources transferred from the first account, and transfers the first type of digital resources from the first contract account to the first account A fourth quantity of digital resources of the second category is transferred.

在一个实施例中,每个转账事件的转入方或转出方为目标账户。In one embodiment, the transfer-in or transfer-out party of each transfer event is the target account.

在一个实施例中,各类数字资源涉及第三类数字资源;资源价值确定模块340包括:汇率确定单元341,配置为确定第三类数字资源与第四类数字资源之间的汇率,第四类数字资源具有预设价值;价值确定单元342,配置为根据汇率和预设价值,确定第三类数字资源的资源价值。In one embodiment, various types of digital resources involve a third type of digital resource; the resource value determination module 340 includes: an exchange rate determination unit 341 configured to determine the exchange rate between the third type of digital resource and the fourth type of digital resource, the fourth The category digital resource has a preset value; the value determining unit 342 is configured to determine the resource value of the third category digital resource according to the exchange rate and the preset value.

在一个具体的实施例中,汇率确定单元341具体配置为:根据在目标交易中以及在目标交易之前发生的数字资源数量的更新事件,确定第三类数字资源和第四类数字资源各自在对应资源池中的资源数量,更新事件通过解析区块链中存储的多个交易的交易数据而得到;将资源数量代入针对第三类数字资源和第四类数字资源预先设定的汇率计算式,求解出汇率。In a specific embodiment, the exchange rate determination unit 341 is specifically configured to: according to the update event of the quantity of digital resources that occurred in the target transaction and before the target transaction, determine the corresponding digital resources of the third type and the fourth type The number of resources in the resource pool, the update event is obtained by parsing the transaction data of multiple transactions stored in the blockchain; substituting the number of resources into the preset exchange rate calculation formula for the third type of digital resources and the fourth type of digital resources, Solve for the exchange rate.

在一个实施例中,资源价值确定模块340具体配置为:将第四类数字资源具有的预设价值,作为第四类数字资源的资源价值。In one embodiment, the resource value determining module 340 is specifically configured to: use the preset value of the fourth type of digital resource as the resource value of the fourth type of digital resource.

在一个实施例中,目标交易涉及若干类数字资源,目标账户在目标交易执行前具有初始数字资源;价值变化确定模块350具体配置为:确定初始数字资源与若干类数字资源之间的类型交集;针对类型交集中的各个类型,确定其在目标交易执行前的初始价值;基于初始数据资源中与各个类型对应的资源数量、资源变化量、初始价值和资源价值,确定价值变化量。In one embodiment, the target transaction involves several types of digital resources, and the target account has initial digital resources before the execution of the target transaction; the value change determination module 350 is specifically configured to: determine the type intersection between the initial digital resource and several types of digital resources; For each type in the type intersection, determine its initial value before the execution of the target transaction; based on the resource quantity, resource change, initial value, and resource value corresponding to each type in the initial data resource, determine the value change.

在一个实施例中,每个转账事件的转入方或转出方为目标账户和目标交易的发起账户之一;资源变化确定模块330具体配置为:确定目标账户和发起账户共同针对各类数字资源的资源变化量;价值变化确定模块350具体配置为:确定目标交易为目标账户和发起账户共同产生的价值变化量。In one embodiment, the transfer-in party or transfer-out party of each transfer event is one of the target account and the originating account of the target transaction; the resource change determination module 330 is specifically configured to: Resource change amount of resource; value change determining module 350 is specifically configured to: determine the target transaction as the value change amount generated jointly by the target account and the initiating account.

在一个具体的实施例中,装置300还包括:风险判定模块360,配置为判断价值变化量是否大于预设增量阈值;在判断出大于的情况下,判定目标交易为风险交易。In a specific embodiment, the device 300 further includes: a risk judging module 360 configured to judge whether the value change is greater than a preset increment threshold; if it is judged to be greater than the value, it is judged that the target transaction is a risk transaction.

本说明书实施例还提供一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行如图2所示的方法。The embodiment of this specification also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed in a computer, the computer is instructed to execute the method shown in FIG. 2 .

本说明书实施例还提供一种计算设备,包括存储器和处理器,所述存储器中存储有可执行代码,所述处理器执行所述可执行代码时,实现如图2所示的方法。The embodiment of this specification also provides a computing device, including a memory and a processor, where executable code is stored in the memory, and when the processor executes the executable code, the method shown in FIG. 2 is implemented.

在20世纪90年代,对于一个技术的改进可以很明显地区分是硬件上的改进(例如,对二极管、晶体管、开关等电路结构的改进)还是软件上的改进(对于方法流程的改进)。然而,随着技术的发展,当今的很多方法流程的改进已经可以视为硬件电路结构的直接改进。设计人员几乎都通过将改进的方法流程编程到硬件电路中来得到相应的硬件电路结构。因此,不能说一个方法流程的改进就不能用硬件实体模块来实现。例如,可编程逻辑器件(Programmable Logic Device,PLD)(例如现场可编程门阵列(Field Programmable GateArray,FPGA))就是这样一种集成电路,其逻辑功能由用户对器件编程来确定。由设计人员自行编程来把一个数字系统“集成”在一片PLD上,而不需要请芯片制造厂商来设计和制作专用的集成电路芯片。而且,如今,取代手工地制作集成电路芯片,这种编程也多半改用“逻辑编译器(logic compiler)”软件来实现,它与程序开发撰写时所用的软件编译器相类似,而要编译之前的原始代码也得用特定的编程语言来撰写,此称之为硬件描述语言(Hardware Description Language,HDL),而HDL也并非仅有一种,而是有许多种,如ABEL(Advanced Boolean Expression Language)、AHDL(Altera Hardware DescriptionLanguage)、Confluence、CUPL(Cornell University Programming Language)、HDCal、JHDL(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(RubyHardware Description Language)等,目前最普遍使用的是VHDL(Very-High-SpeedIntegrated Circuit Hardware Description Language)与Verilog。本领域技术人员也应该清楚,只需要将方法流程用上述几种硬件描述语言稍作逻辑编程并编程到集成电路中,就可以很容易得到实现该逻辑方法流程的硬件电路。In the 1990s, the improvement of a technology can be clearly distinguished as an improvement in hardware (for example, improvements in circuit structures such as diodes, transistors, and switches) or improvements in software (improvement in method flow). However, with the development of technology, the improvement of many current method flows can be regarded as the direct improvement of the hardware circuit structure. Designers almost always get the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (Programmable Logic Device, PLD) (such as a Field Programmable Gate Array (Field Programmable Gate Array, FPGA)) is such an integrated circuit, and its logic function is determined by programming the device by a user. It is programmed by the designer to "integrate" a digital system on a PLD, instead of asking a chip manufacturer to design and make a dedicated integrated circuit chip. Moreover, nowadays, instead of making integrated circuit chips by hand, this kind of programming is mostly realized by "logic compiler (logic compiler)" software, which is similar to the software compiler used when writing programs. The original code of the computer must also be written in a specific programming language, which is called a hardware description language (Hardware Description Language, HDL), and there is not only one kind of HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language) , AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc., currently the most commonly used is VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. It should also be clear to those skilled in the art that only a little logical programming of the method flow in the above-mentioned hardware description languages and programming into an integrated circuit can easily obtain a hardware circuit for realizing the logic method flow.

控制器可以按任何适当的方式实现,例如,控制器可以采取例如微处理器或处理器以及存储可由该(微)处理器执行的计算机可读程序代码(例如软件或固件)的计算机可读介质、逻辑门、开关、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程逻辑控制器和嵌入微控制器的形式,控制器的例子包括但不限于以下微控制器:ARC 625D、Atmel AT91SAM、Microchip PIC18F26K20以及Silicone Labs C8051F320,存储器控制器还可以被实现为存储器的控制逻辑的一部分。本领域技术人员也知道,除了以纯计算机可读程序代码方式实现控制器以外,完全可以通过将方法步骤进行逻辑编程来使得控制器以逻辑门、开关、专用集成电路、可编程逻辑控制器和嵌入微控制器等的形式来实现相同功能。因此这种控制器可以被认为是一种硬件部件,而对其内包括的用于实现各种功能的装置也可以视为硬件部件内的结构。或者甚至,可以将用于实现各种功能的装置视为既可以是实现方法的软件模块又可以是硬件部件内的结构。The controller may be implemented in any suitable way, for example the controller may take the form of a microprocessor or processor and a computer readable medium storing computer readable program code (such as software or firmware) executable by the (micro)processor , logic gates, switches, Application Specific Integrated Circuit (ASIC), programmable logic controllers, and embedded microcontrollers, examples of controllers include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicone Labs C8051F320, the memory controller can also be implemented as part of the memory's control logic. Those skilled in the art also know that, in addition to realizing the controller in a purely computer-readable program code mode, it is entirely possible to make the controller use logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded The same function can be realized in the form of a microcontroller or the like. Therefore, such a controller can be regarded as a hardware component, and the devices included in it for realizing various functions can also be regarded as structures within the hardware component. Or even, means for realizing various functions can be regarded as a structure within both a software module realizing a method and a hardware component.

上述实施例阐明的系统、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为服务器系统。当然,本申请不排除随着未来计算机技术的发展,实现上述实施例功能的计算机例如可以为个人计算机、膝上型计算机、车载人机交互设备、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任何设备的组合。The systems, devices, modules, or units described in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a server system. Of course, the present application does not exclude that with the development of future computer technology, the computer that realizes the functions of the above embodiments can be, for example, a personal computer, a laptop computer, a vehicle-mounted human-computer interaction device, a cellular phone, a camera phone, a smart phone, a personal digital assistant , media players, navigation devices, email devices, game consoles, tablet computers, wearable devices, or any combination of these devices.

虽然本说明书一个或多个实施例提供了如实施例或流程图所述的方法操作步骤,但基于常规或者无创造性的手段可以包括更多或者更少的操作步骤。实施例中列举的步骤顺序仅仅为众多步骤执行顺序中的一种方式,不代表唯一的执行顺序。在实际中的装置或终端产品执行时,可以按照实施例或者附图所示的方法顺序执行或者并行执行(例如并行处理器或者多线程处理的环境,甚至为分布式数据处理环境)。术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、产品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、产品或者设备所固有的要素。在没有更多限制的情况下,并不排除在包括所述要素的过程、方法、产品或者设备中还存在另外的相同或等同要素。例如若使用到第一,第二等词语用来表示名称,而并不表示任何特定的顺序。Although one or more embodiments of the present specification provide the operation steps of the method described in the embodiment or the flowchart, more or fewer operation steps may be included based on conventional or non-inventive means. The sequence of steps enumerated in the embodiments is only one of the execution sequences of many steps, and does not represent the only execution sequence. When an actual device or terminal product is executed, the methods shown in the embodiments or drawings can be executed sequentially or in parallel (such as a parallel processor or multi-thread processing environment, or even a distributed data processing environment). The term "comprising", "comprising" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, product, or apparatus comprising a set of elements includes not only those elements, but also other elements not expressly listed elements, or also elements inherent in such a process, method, product, or apparatus. Without further limitations, it is not excluded that there are additional identical or equivalent elements in a process, method, product or device comprising said elements. For example, if the words first, second, etc. are used, they are used to indicate names and do not indicate any specific order.

为了描述的方便,描述以上装置时以功能分为各种模块分别描述。当然,在实施本说明书一个或多个时可以把各模块的功能在同一个或多个软件和/或硬件中实现,也可以将实现同一功能的模块由多个子模块或子单元的组合实现等。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。For the convenience of description, when describing the above devices, functions are divided into various modules and described separately. Of course, when implementing one or more of the present specification, the functions of each module can be realized in the same or more software and/or hardware, and the modules that realize the same function can also be realized by a combination of multiple submodules or subunits, etc. . The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated. to another system, or some features may be ignored, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.

本发明是参照根据本发明实施例的方法、装置(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It should be understood that each procedure and/or block in the flowchart and/or block diagram, and a combination of procedures and/or blocks in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions may be provided to a general purpose computer, special purpose computer, embedded processor, or processor of other programmable data processing equipment to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing equipment produce a An apparatus for realizing the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions The device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.

这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device, causing a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby The instructions provide steps for implementing the functions specified in the flow chart or blocks of the flowchart and/or the block or blocks of the block diagrams.

在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.

内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。Memory may include non-permanent storage in computer readable media, in the form of random access memory (RAM) and/or nonvolatile memory such as read only memory (ROM) or flash RAM. Memory is an example of computer readable media.

计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储、石墨烯存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can be implemented by any method or technology for storage of information. Information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Flash memory or other memory technology, Compact Disc Read-Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, Magnetic cassettes, magnetic tape magnetic disk storage, graphene storage or other magnetic storage devices or any other non-transmission medium that can be used to store information that can be accessed by computing devices. As defined herein, computer-readable media excludes transitory computer-readable media, such as modulated data signals and carrier waves.

本领域技术人员应明白,本说明书一个或多个实施例可提供为方法、系统或计算机程序产品。因此,本说明书一个或多个实施例可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本说明书一个或多个实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that one or more embodiments of this specification may be provided as a method, system or computer program product. Accordingly, one or more embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, one or more embodiments of the present description may employ a computer program embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein. The form of the product.

本说明书一个或多个实施例可以在由计算机执行的计算机可执行指令的一般上下文中描5述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本本说明书一个或多个实施例,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。One or more embodiments of this specification may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. One or more embodiments of the present specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network.

在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。In a distributed computing environment, program modules may be located in both local and remote computer storage media including storage devices.

本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相0参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而Each embodiment in this specification is described in a progressive manner, the same and similar parts of each embodiment can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment and

言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、In other words, since it is basically similar to the method embodiment, the description is relatively simple, and for relevant parts, please refer to the part of the description of the method embodiment. In the description of this specification, reference is made to the terms "one embodiment", "some embodiments", "example",

“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本说明书的至少一个实施例或示例中。在本说明书中,对上述术语的示5意性表述不必须针对的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特The description of "specific examples" or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiments or examples are included in at least one embodiment or example in this specification. In this specification, the schematic representations of the above terms are not necessarily directed to the same embodiment or example. Furthermore, no particular feature, structure, material, or characteristic described

点可以在任一个或多个实施例或示例中以合适的方式结合。此外,在不相互矛盾的情况下,本领域的技术人员可以将本说明书中描述的不同实施例或示例以及不同实施例或示例的特征进行结合和组合。Points may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine different embodiments or examples and features of different embodiments or examples described in this specification without conflicting with each other.

以上所述仅为本说明书一个或多个实施例的实施例而已,并不用于限制本本说明书一个0或多个实施例。对于本领域技术人员来说,本说明书一个或多个实施例可以有各种更改和变The above description is only an example of one or more embodiments of this specification, and is not intended to limit one or more embodiments of this specification. For those skilled in the art, one or more embodiments of this description may have various modifications and changes.

化。凡在本说明书的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在权利要求范围之内。change. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of this specification shall be included in the scope of the claims.

Claims (16)

1.一种针对区块链交易的检测方法,包括:1. A detection method for blockchain transactions, comprising: 获取区块链上目标交易的交易数据,所述目标交易调用目标智能合约;所述目标智能合约的业务逻辑包括:从合约账户中转出第一数量的目标类数字资源发放至目标账户,以及,从目标账户中转出第二数量的目标类数字资源归还至所述合约账户;Obtain the transaction data of the target transaction on the block chain, the target transaction calls the target smart contract; the business logic of the target smart contract includes: transferring the first amount of target digital resources from the contract account to the target account, and , transferring the second quantity of target digital resources from the target account and returning them to the contract account; 从所述交易数据中解析出若干转账事件,其中每个转账事件包括转入方、转出方、数字资源类型,以及针对该类型的数字资源发生转账的数量;Analyzing a number of transfer events from the transaction data, where each transfer event includes the transfer-in party, the transfer-out party, the type of digital resource, and the amount of transfer for this type of digital resource; 根据上述若干转账事件,确定所述目标账户针对各类数字资源的资源变化量;According to the above-mentioned several transfer events, determine the amount of resource change of the target account for various digital resources; 获取所述各类数字资源在所述目标交易执行完成时的资源价值;Obtain the resource value of the various digital resources when the target transaction is executed; 基于所述资源变化量和资源价值,确定所述目标交易为所述目标账户产生的价值变化量,用于判定所述目标交易的风险性。Based on the resource change amount and resource value, determine the value change amount generated by the target transaction for the target account, and use it to determine the risk of the target transaction. 2.根据权利要求1所述的方法,其中,所述交易数据包括以下至少一项:交易体、交易日志,所述交易日志中包括所述若干转账事件。2. The method according to claim 1, wherein the transaction data includes at least one of the following: a transaction body and a transaction log, and the transaction log includes the several transfer events. 3.根据权利要求1所述的方法,其中,获取区块链上目标交易的交易数据,包括:3. The method according to claim 1, wherein obtaining the transaction data of the target transaction on the block chain comprises: 获取区块链中存储的多个交易的交易数据;Get transaction data for multiple transactions stored in the blockchain; 基于所述多个交易的交易数据,筛选出调用预先设定的目标函数的若干交易;所述目标函数用于实现所述业务逻辑;Based on the transaction data of the plurality of transactions, filter out several transactions that call a preset target function; the target function is used to realize the business logic; 将所述若干交易中的每个交易分别作为所述目标交易。Each of the plurality of transactions is used as the target transaction. 4.根据权利要求3所述的方法,其中,基于所述多个交易的交易数据,筛选出调用预先设定的目标函数的若干交易,包括:4. The method according to claim 3, wherein, based on the transaction data of the plurality of transactions, screening out several transactions that call a preset objective function, comprising: 从所述多个交易中去除交易数据涉及的转账事件个数小于预设个数阈值的交易;removing from the plurality of transactions transactions in which the number of transfer events involved in the transaction data is less than a preset number threshold; 基于剩余交易的交易数据,从该剩余交易中筛选出所述若干交易。Based on the transaction data of the remaining transactions, the plurality of transactions are selected from the remaining transactions. 5.根据权利要求1所述的方法,其中,所述目标交易还调用其他的若干智能合约,其中包括的第一智能合约用于提供不同类型的数字资源之间的兑换服务。5. The method according to claim 1, wherein the target transaction also invokes several other smart contracts, wherein the first smart contract included is used to provide exchange services between different types of digital resources. 6.根据权利要求5所述的方法,其中,所述第一智能合约的业务逻辑包括:第一合约账户接收从第一账户转出的第三数量的第一类数字资源,并且,从所述第一合约账户向第一账户转入第四数量的第二类数字资源。6. The method according to claim 5, wherein the business logic of the first smart contract includes: the first contract account receives a third amount of the first type of digital resources transferred from the first account, and, from the The above-mentioned first contract account is transferred to the first account with a fourth quantity of the second type of digital resources. 7.根据权利要求1所述的方法,其中,所述每个转账事件的转入方或转出方为所述目标账户。7. The method according to claim 1, wherein the transfer-in or transfer-out party of each transfer event is the target account. 8.根据权利要求1所述的方法,其中,所述各类数字资源涉及第三类数字资源;其中,获取所述各类数字资源在所述目标交易执行完成时的资源价值,包括:8. The method according to claim 1, wherein the various types of digital resources involve a third type of digital resources; wherein obtaining the resource value of the various types of digital resources when the execution of the target transaction is completed comprises: 确定所述第三类数字资源与第四类数字资源之间的汇率,所述第四类数字资源具有预设价值;determining an exchange rate between the third type of digital resource and the fourth type of digital resource, the fourth type of digital resource having a preset value; 根据所述汇率和预设价值,确定所述第三类数字资源的资源价值。Determine the resource value of the third type of digital resource according to the exchange rate and the preset value. 9.根据权利要求8所述的方法,其中,确定所述第三类数字资源与第四类数字资源之间的汇率,包括:9. The method according to claim 8, wherein determining the exchange rate between the third type of digital resource and the fourth type of digital resource comprises: 根据在所述目标交易中以及在所述目标交易之前发生的数字资源数量的更新事件,确定所述第三类数字资源和第四类数字资源各自在对应资源池中的资源数量,所述更新事件通过解析区块链中存储的多个交易的交易数据而得到;According to the update event of the number of digital resources that occurred in the target transaction and before the target transaction, determine the respective resource quantities of the third type of digital resources and the fourth type of digital resources in the corresponding resource pools, the updating The event is obtained by parsing the transaction data of multiple transactions stored in the blockchain; 将所述资源数量代入针对第三类数字资源和第四类数字资源预先设定的汇率计算式,求解出所述汇率。The exchange rate is obtained by substituting the amount of resources into the preset exchange rate calculation formula for the third type of digital resources and the fourth type of digital resources. 10.根据权利要求1所述的方法,其中,所述各类数字资源涉及第四类数字资源;其中,获取所述各类数字资源在所述目标交易执行完成时的资源价值,包括:10. The method according to claim 1, wherein the various types of digital resources relate to the fourth type of digital resources; wherein obtaining the resource value of the various types of digital resources when the target transaction is executed comprises: 将所述第四类数字资源具有的预设价值,作为所述第四类数字资源的资源价值。The preset value of the fourth type of digital resource is used as the resource value of the fourth type of digital resource. 11.根据权利要求1所述的方法,其中,所述目标交易涉及若干类数字资源,所述目标账户在所述目标交易执行前具有初始数字资源;其中,基于所述资源变化量和资源价值,确定所述目标交易为所述目标账户产生的价值变化量,包括:11. The method according to claim 1, wherein the target transaction involves several types of digital resources, and the target account has initial digital resources before the execution of the target transaction; wherein, based on the resource variation and resource value , to determine the amount of value change generated by the target transaction for the target account, including: 确定所述初始数字资源与所述若干类数字资源之间的类型交集;determining a type intersection between the initial digital resource and the types of digital resources; 针对所述类型交集中的各个类型,确定其在所述目标交易执行前的初始价值;For each type in the type intersection, determine its initial value before the execution of the target transaction; 基于所述初始数据资源中与所述各个类型对应的资源数量、所述资源变化量、所述初始价值和所述资源价值,确定所述价值变化量。The value change amount is determined based on the resource quantity corresponding to each type in the initial data resource, the resource change amount, the initial value, and the resource value. 12.根据权利要求1所述的方法,其中,每个转账事件的转入方或转出方为所述目标账户和所述目标交易的发起账户之一;其中,确定所述目标账户针对各类数字资源的资源变化量,包括:12. The method according to claim 1, wherein the transfer-in party or transfer-out party of each transfer event is one of the target account and the originating account of the target transaction; wherein it is determined that the target account is for each The amount of resource changes of similar digital resources, including: 确定所述目标账户和发起账户共同针对所述各类数字资源的资源变化量;Determining the resource change amount of the target account and the initiating account for the various digital resources; 其中,确定所述目标交易为所述目标账户产生的价值变化量,包括:Wherein, determining the value variation generated by the target transaction for the target account includes: 确定所述目标交易为所述目标账户和所述发起账户共同产生的价值变化量。The target transaction is determined to be a value change jointly generated by the target account and the initiating account. 13.根据权利要求1-12中任一项所述的方法,其中,在确定所述目标交易为所述目标账户产生的价值变化量之后,所述方法还包括:13. The method according to any one of claims 1-12, wherein, after determining the amount of value change generated by the target transaction for the target account, the method further comprises: 判断所述价值变化量是否大于预设增量阈值;Judging whether the value change is greater than a preset increment threshold; 在判断出大于的情况下,判定所述目标交易为风险交易。If it is judged to be greater than , it is judged that the target transaction is a risk transaction. 14.一种针对区块链交易的检测装置,包括:14. A detection device for blockchain transactions, comprising: 交易数据获取模块,配置为获取区块链上目标交易的交易数据,所述目标交易调用目标智能合约;所述目标智能合约的业务逻辑包括:从合约账户中转出第一数量的目标类数字资源发放至目标账户,以及,从目标账户中转出第二数量的目标类数字资源归还至所述合约账户;The transaction data acquisition module is configured to obtain the transaction data of the target transaction on the block chain, and the target transaction calls the target smart contract; the business logic of the target smart contract includes: transferring the first number of target class numbers from the contract account The resources are distributed to the target account, and the second quantity of target digital resources transferred from the target account is returned to the contract account; 转账事件确定模块,配置为从所述交易数据中解析出若干转账事件,其中每个转账事件包括转入方、转出方、数字资源类型,以及针对该类型的数字资源发生转账的数量;A transfer event determination module configured to parse out a number of transfer events from the transaction data, where each transfer event includes the transfer-in party, the transfer-out party, the type of digital resource, and the amount transferred for this type of digital resource; 资源变化确定模块,配置为根据上述若干转账事件,确定所述目标账户针对各类数字资源的资源变化量;The resource change determination module is configured to determine the resource change amount of the target account for various digital resources according to the above-mentioned several transfer events; 资源价值确定模块,配置为获取所述各类数字资源在所述目标交易执行完成时的资源价值;The resource value determination module is configured to obtain the resource value of the various digital resources when the execution of the target transaction is completed; 价值变化确定模块,配置为基于所述资源变化量和资源价值,确定所述目标交易为所述目标账户产生的价值变化量,用于判定所述目标交易的风险性。The value change determining module is configured to determine the value change amount generated by the target transaction for the target account based on the resource change amount and the resource value, for determining the risk of the target transaction. 15.一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行权利要求1-13中任一项的所述的方法。15. A computer-readable storage medium, on which a computer program is stored, and when the computer program is executed in a computer, it causes the computer to execute the method according to any one of claims 1-13. 16.一种区块链节点,包括存储器和处理器,所述存储器中存储有可执行代码,所述处理器执行所述可执行代码时,实现权利要求1-13中任一项所述的方法。16. A blockchain node, comprising a memory and a processor, wherein executable code is stored in the memory, and when the processor executes the executable code, it realizes any one of claims 1-13 method.
CN202211522132.1A 2022-11-30 2022-11-30 Detection method and device for blockchain transaction Pending CN116308372A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211522132.1A CN116308372A (en) 2022-11-30 2022-11-30 Detection method and device for blockchain transaction

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211522132.1A CN116308372A (en) 2022-11-30 2022-11-30 Detection method and device for blockchain transaction

Publications (1)

Publication Number Publication Date
CN116308372A true CN116308372A (en) 2023-06-23

Family

ID=86831145

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211522132.1A Pending CN116308372A (en) 2022-11-30 2022-11-30 Detection method and device for blockchain transaction

Country Status (1)

Country Link
CN (1) CN116308372A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116862679A (en) * 2023-09-04 2023-10-10 腾讯科技(深圳)有限公司 Block chain-based data processing method, device, equipment and readable storage medium
CN116882998A (en) * 2023-09-08 2023-10-13 成都链安科技有限公司 Virtual currency fund analysis method

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109003184A (en) * 2018-06-22 2018-12-14 中链科技有限公司 Block chain assets management method and device
CN110930013A (en) * 2019-11-15 2020-03-27 腾讯科技(深圳)有限公司 Data processing method, device, server and storage medium
WO2021040692A1 (en) * 2019-08-26 2021-03-04 Compound Labs, Inc. Systems and methods for pooling and transferring digital assets
US20210133735A1 (en) * 2018-01-15 2021-05-06 Enrico Maim Token-based transactional systems and methods
CN113298653A (en) * 2021-05-27 2021-08-24 李政德 Block chain-based data tampering monitoring method and device
CN114418578A (en) * 2022-03-30 2022-04-29 北京溪塔科技有限公司 Block chain account risk query method and device
CN115271743A (en) * 2022-08-05 2022-11-01 中国电信股份有限公司 Block chain arbitrage behavior detection method and device, storage medium and electronic equipment

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20210133735A1 (en) * 2018-01-15 2021-05-06 Enrico Maim Token-based transactional systems and methods
CN109003184A (en) * 2018-06-22 2018-12-14 中链科技有限公司 Block chain assets management method and device
WO2021040692A1 (en) * 2019-08-26 2021-03-04 Compound Labs, Inc. Systems and methods for pooling and transferring digital assets
CN110930013A (en) * 2019-11-15 2020-03-27 腾讯科技(深圳)有限公司 Data processing method, device, server and storage medium
CN113298653A (en) * 2021-05-27 2021-08-24 李政德 Block chain-based data tampering monitoring method and device
CN114418578A (en) * 2022-03-30 2022-04-29 北京溪塔科技有限公司 Block chain account risk query method and device
CN115271743A (en) * 2022-08-05 2022-11-01 中国电信股份有限公司 Block chain arbitrage behavior detection method and device, storage medium and electronic equipment

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116862679A (en) * 2023-09-04 2023-10-10 腾讯科技(深圳)有限公司 Block chain-based data processing method, device, equipment and readable storage medium
CN116862679B (en) * 2023-09-04 2023-11-21 腾讯科技(深圳)有限公司 Block chain-based data processing method, device, equipment and readable storage medium
CN116882998A (en) * 2023-09-08 2023-10-13 成都链安科技有限公司 Virtual currency fund analysis method
CN116882998B (en) * 2023-09-08 2023-11-24 成都链安科技有限公司 Virtual currency fund analysis method

Similar Documents

Publication Publication Date Title
US10929198B2 (en) Blockchain-based resource allocation method and apparatus
EP3780541B1 (en) Identity information identification method and device
EP3565219B1 (en) Service execution method and device
CN116308372A (en) Detection method and device for blockchain transaction
CN112560114B (en) Method and device for calling intelligent contract
CN112511651B (en) Service access method and device based on block chain
CN111553695B (en) Cross-region payment method and device and electronic equipment
WO2024001032A1 (en) Method for executing transaction in blockchain system, and blockchain system and nodes
TWI686758B (en) Data request processing, inquiry message processing method, device and equipment
CN105431815A (en) Input-output prioritization for database workload
CN115983997A (en) Blockchain-based collection management method, blockchain node and system
CN111708994A (en) Risk management method, device, equipment and medium
WO2025139351A1 (en) Calling of smart contract
WO2025092876A1 (en) Transaction processing method and blockchain node in blockchain system
CN108920326A (en) Determine system time-consuming abnormal method, apparatus and electronic equipment
WO2024244342A1 (en) Transaction processing method in blockchain, and blockchain node
CN109614415B (en) Data mining and processing method, device, equipment and medium
CN112215602A (en) Data query method, device and system and electronic equipment
WO2024221910A1 (en) Transaction execution method and blockchain node in blockchain system
WO2025025436A1 (en) Data management method based on blockchain system, and blockchain node
CN116614407A (en) Risk control method and device
CN114968422A (en) Method and apparatus for automatically executing contracts based on variable states
CN115114334A (en) Method and device for querying data in block chain
CN115865365B (en) Block chain-based account dividing processing method, device and system
CN113706154B (en) A transaction risk detection method, device and equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载