# US 11,113,271 B2 · Methods and devices for performing off-chain testing on smart contract

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 11,113,271 B2
- Document ID: US11113271B2
- Status: Granted
- Kind: B2
- Application number: 16/721,265
- Filed: 2019-12-19
- Published: 2020-09-10
- Granted: 2021-09-07
- Earliest claimed: 2019-03-04
- Assignees: Advanced New Technologies Co., Ltd.
- Applicants: Advanced New Technologies Co., Ltd.
- Inventors: Haizhen Zhuo; Honglin Qiu
- Web page: https://patentgrep.com/patent/US11113271B2

## CPC

- G06F 16/2379: {Updates performed during online database operations; commit processing}
- H04L 9/3239: {involving non-keyed hash functions, e.g. modification detection codes [MDCs], MD5, SHA or RIPEMD}
- G06F 9/54: Interprogram communication
- G06F 16/2365: {Ensuring data consistency and integrity}
- G06Q 20/389: {Keeping log of transactions for guaranteeing non-repudiation of a transaction}
- H04L 9/0637: {Modes of operation, e.g. cipher block chaining [CBC], electronic codebook [ECB] or Galois/counter mode [GCM]}
- H04L 9/0643: {Hash functions, e.g. MD5, SHA, HMAC or f9 MAC}
- H04L 9/50: {using hash chains, e.g. blockchains or hash trees}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- H04L: TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION (arrangements common to telegraphic and telephonic communication H04M)
- G06Q: INFORMATION 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

## Abstract

Disclosed herein are methods, devices, and apparatuses, including computer programs stored on computer-readable media, for performing an off-chain testing on a smart contract. One of the methods includes: generating execution environment information for the smart contract, the execution environment information including at least one of transaction context information, blockchain information, or state information; providing an interface between the generated execution environment information and the smart contract; executing the smart contract based on the generated execution environment information and the provided interface; and storing an execution result of the smart contract.

## Claims

### Claim 1

A computer-implemented method for performing an off-chain testing on a smart contract, comprising:
generating execution environment information for the smart contract, the execution environment information including at least one of transaction context information, blockchain information, or state information;
providing an interface between the generated execution environment information and the smart contract;
executing the smart contract based on the generated execution environment information and the provided interface; and
storing an execution result of the smart contract, wherein the storing the execution result comprises storing data indicating a change in at least one of the blockchain information or the state information,
wherein the generating the execution environment information, the providing the interface, the executing the smart contract, and the storing the execution result of the smart contract are performed before the smart contract is deployed into a blockchain, thereby implementing the off-chain testing on the smart contract.

### Claim 2 (depends on 1)

The method of claim 1, where the generating the execution environment information comprises:
generating the transaction context information to include at least one of an address of the smart contract, a transaction identifier of a transaction, or party information of the transaction.

### Claim 3 (depends on 1)

The method of claim 1, where the generating the execution environment information comprises:
generating the blockchain information to include at least one of a block identifier for a current block, a timestamp of the current block, and a hash value of a previous block.

### Claim 4 (depends on 1)

The method of claim 1, where the generating the execution environment information comprises:
generating the state information to include at least one of parameter information of the smart contract or transaction information.

### Claim 5 (depends on 1)

The method of claim 1, wherein the providing the interface comprises:
providing an application program interface (API) between the generated execution environment information and the smart contract.

### Claim 6 (depends on 1)

The method of claim 1, wherein the transaction context information corresponds to a first transaction, the method further comprising:
generating updated transaction context information corresponding to a second transaction; and
updating the execution environment information with the data indicating a change in at least one of the blockchain information or the state information, and the updated transaction context information.

### Claim 7 (depends on 6)

The method of claim 6, further comprising:
executing the smart contract based on the updated execution environment information and the provided interface; and
storing another execution result of the smart contract.

### Claim 8 (depends on 1)

The method of claim 1, further comprising:
displaying the execution result of the smart contract for verification.

### Claim 9

A device for performing an off-chain testing on a smart contract, comprising:
one or more processors; and
one or more computer-readable memories coupled to the one or more processors and having instructions stored thereon that are executable by the one or more processors, wherein the one or more processors are configured to:
generate execution environment information for the smart contract, the execution environment information including at least one of transaction context information, blockchain information, or state information;
provide an interface between the generated execution environment information and the smart contract;
execute the smart contract based on the generated execution environment information and the provided interface; and
store an execution result of the smart contract, wherein storing the execution result comprises storing data indicating a change in at least one of the blockchain information or the state information,
wherein generating the execution environment information, providing the interface, executing the smart contract, and storing the execution result of the smart contract are performed before the smart contract is deployed into a blockchain, thereby implementing the off-chain testing on the smart contract.

### Claim 10 (depends on 9)

The device of claim 9, wherein in generating the execution environment information, the one or more processors are further configured to:
generate the transaction context information to include at least one of an address of the smart contract, a transaction identifier of a transaction, or party information of the transaction.

### Claim 11 (depends on 9)

The device of claim 9, wherein in generating the execution environment information, the one or more processors are further configured to:
generate the blockchain information to include at least one of a block identifier for a current block, a timestamp of the current block, and a hash value of a previous block.

### Claim 12 (depends on 9)

The device of claim 9, wherein in generating the execution environment information, the one or more processors are further configured to:
generate the state information to include at least one of parameter information of the smart contract or transaction information.

### Claim 13 (depends on 9)

The device of claim 9, wherein in providing the interface, the one or more processors are further configured to:
provide an application program interface (API) between the generated execution environment information and the smart contract.

### Claim 14 (depends on 9)

The device of claim 9, wherein the transaction context information corresponds to a first transaction, and the one or more processors are further configured to:
generate updated transaction context information corresponding to a second transaction; and
update the execution environment information with the data indicating a change in at least one of the blockchain information or the state information, and the updated transaction context information.

### Claim 15 (depends on 14)

The device of claim 14, wherein the one or more processors are further configured to:
execute the smart contract based on the updated execution environment information and the provided interface; and
store another execution result of the smart contract.

### Claim 16 (depends on 9)

The device of claim 9, wherein the one or more processors are further configured to:
display the execution result of the smart contract for verification.

### Claim 17

A non-transitory computer-readable medium having stored therein instructions that, when executed by a processor of a device, cause the device to perform a method for performing an off-chain testing on a smart contract, the method comprising:
generating execution environment information for the smart contract, the execution environment information including at least one of transaction context information, blockchain information, or state information;
providing an interface between the generated execution environment information and the smart contract;
executing the smart contract based on the generated execution environment information and the provided interface; and
storing an execution result of the smart contract, wherein the storing the execution result comprises storing data indicating a change in at least one of the blockchain information or the state information,
wherein the generating the execution environment information, the providing the interface, the executing the smart contract, and the storing the execution result of the smart contract are performed before the smart contract is deployed into a blockchain, thereby implementing the off-chain testing on the smart contract.
