# US 2021/0064784 A1 · Managing a smart contract on a blockchain

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

- Number: US 2021/0064784 A1
- Document ID: US20210064784A1
- Status: Published application
- Kind: A1
- Application number: 17/098,124
- Filed: 2020-11-13
- Published: 2021-03-04
- Earliest claimed: 2019-05-30
- Assignees: Advanced New Technologies Co., Ltd.
- Applicants: Advanced New Technologies Co., Ltd.
- Inventors: Changzheng Wei; Ying Yan
- Web page: https://patentgrep.com/patent/US20210064784A1

## CPC

- G06F 21/64: Protecting data integrity, e.g. using checksums, certificates or signatures
- G06F 21/602: {Providing cryptographic facilities or services}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A computer-implemented method includes: in response to a first client device invoking a transaction with respect to a target smart contract, obtaining, by a blockchain node device in a blockchain, encrypted contract codes of the target smart contract; transmitting the encrypted contract codes of the target smart contract to a trusted execution environment; in response to determining that the target smart contract is not a managed smart contract, extracting a decryption key stored in the trusted execution environment, in which the decryption key corresponds to the encrypted contract codes of the target smart contract; decrypting the encrypted contract codes of the target smart contract; executing the decrypted contract codes of the target smart contract in the trusted execution environment; encrypting the execution result; and transmitting the encrypted execution result to the distributed ledgers of the blockchain for storage.

## Claims

### Claim at position 1

-20. (canceled)

### Claim 21

A computer-implemented method comprising:
in response to a first client device invoking a transaction with respect to a target smart contract, obtaining, by a blockchain node device in a blockchain, encrypted contract codes of the target smart contract, wherein the encrypted contract codes are stored in distributed ledgers of the blockchain, and wherein a trusted execution environment is installed on the blockchain node device;
transmitting the encrypted contract codes of the target smart contract to the trusted execution environment;
extracting a decryption key stored in the trusted execution environment, wherein the decryption key corresponds to the encrypted contract codes of the target smart contract;
decrypting the encrypted contract codes of the target smart contract using the extracted decryption key, to obtain decrypted contract codes;
executing the decrypted contract codes of the target smart contract in the trusted execution environment to obtain an execution result;
obtaining a smart contract management rule;
determining, in the trusted execution environment, that the target smart contract is a managed smart contract based on the smart contract management rule; and
in response to determining that the target smart contract is a managed smart contract, transmitting, to the first client device, a failure message.

### Claim 22 (depends on 21)

The computer-implemented method of claim 21, further comprising:
in response to determining that the target smart contract is a managed smart contract, deleting the execution result.

### Claim 23 (depends on 21)

The computer-implemented method of claim 21, further comprising, in response to determining that the target smart contract is a managed smart contract:
storing the execution result in the trusted execution environment, and
setting the execution result stored in the trusted execution environment as extraction-prohibited.

### Claim 24 (depends on 21)

The computer-implemented method of claim 21, further comprising:
receiving creation transaction data corresponding to a creation transaction initiated by a second client device with respect to the target smart contract, wherein the creation transaction data comprises the encrypted contract codes of the target smart contract;
in response to receiving the creation transaction data, creating the target smart contract by executing smart contract creation codes in the trusted execution environment;
creating a contract account on the blockchain, wherein the contract account corresponds to the target smart contract; and
transmitting the encrypted contract codes of the target smart contract to the distributed ledgers of the blockchain for storage.

### Claim 25 (depends on 21)

The computer-implemented method of claim 21, wherein obtaining the smart contract management rule comprises:
monitoring, by the blockchain node device, data related to the target smart contract in an independent regulatory blockchain;
in response to a regulatory party generating a latest smart contract regulatory rule by invoking a second smart contract deployed on the independent regulatory blockchain, storing the latest smart contract regulatory rule into a local storage of the blockchain node device; and
reading, as the smart contract management rule, the latest smart contract regulatory rule from the local storage of the blockchain node device.

### Claim 26 (depends on 21)

The computer-implemented method of claim 21, wherein the smart contract management rule comprises a smart contract blacklist comprising contract addresses of managed smart contracts, and
wherein determining that the target smart contract is a managed smart contract based on the smart contract management rule comprises:
obtaining a contract address of the target smart contract;
matching the contract address of the target smart contract against the contract addresses in the smart contract blacklist; and
in response to determining that the contract address of the target smart contract matches one of the contract addresses in the smart contract blacklist, determining that the target smart contract is a managed smart contract.

### Claim 27

A non-transitory, computer-readable medium storing one or more instructions executable by a computer system to perform operations comprising:
in response to a first client device invoking a transaction with respect to a target smart contract, obtaining, by a blockchain node device in a blockchain, encrypted contract codes of the target smart contract, wherein the encrypted contract codes are stored in distributed ledgers of the blockchain, and wherein a trusted execution environment is installed on the blockchain node device;
transmitting the encrypted contract codes of the target smart contract to the trusted execution environment;
extracting a decryption key stored in the trusted execution environment, wherein the decryption key corresponds to the encrypted contract codes of the target smart contract;
decrypting the encrypted contract codes of the target smart contract using the extracted decryption key, to obtain decrypted contract codes;
executing the decrypted contract codes of the target smart contract in the trusted execution environment to obtain an execution result;
obtaining a smart contract management rule;
determining, in the trusted execution environment, that the target smart contract is a managed smart contract based on the smart contract management rule; and
in response to determining that the target smart contract is a managed smart contract, transmitting, to the first client device, a failure message.

### Claim 28 (depends on 27)

The non-transitory, computer-readable medium of claim 27, wherein the operations further comprise, in response to determining that the target smart contract is a managed smart contract, deleting the execution result.

### Claim 29 (depends on 27)

The non-transitory, computer-readable medium of claim 27, wherein the operations further comprise, in response to determining that the target smart contract is a managed smart contract:
storing the execution result in the trusted execution environment, and
setting the execution result stored in the trusted execution environment as extraction-prohibited.

### Claim 30 (depends on 27)

The non-transitory, computer-readable medium of claim 27, wherein the operations further comprise:
receiving creation transaction data corresponding to a creation transaction initiated by a second client device with respect to the target smart contract, wherein the creation transaction data comprises the encrypted contract codes of the target smart contract;
in response to receiving the creation transaction data, creating the target smart contract by executing smart contract creation codes in the trusted execution environment;
creating a contract account on the blockchain, wherein the contract account corresponds to the target smart contract; and
transmitting the encrypted contract codes of the target smart contract to the distributed ledgers of the blockchain for storage.

### Claim 31 (depends on 27)

The non-transitory, computer-readable medium of claim 27, wherein obtaining the smart contract management rule comprises:
monitoring, by the blockchain node device, data related to the target smart contract in an independent regulatory blockchain;
in response to a regulatory party generating a latest smart contract regulatory rule by invoking a second smart contract deployed on the independent regulatory blockchain, storing the latest smart contract regulatory rule into a local storage of the blockchain node device; and
reading, as the smart contract management rule, the latest smart contract regulatory rule from the local storage of the blockchain node device.

### Claim 32 (depends on 27)

The non-transitory, computer-readable medium of claim 27, herein the smart contract management rule comprises a smart contract blacklist comprising contract addresses of managed smart contracts, and
wherein determining that the target smart contract is a managed smart contract based on the smart contract management rule comprises:
obtaining a contract address of the target smart contract;
matching the contract address of the target smart contract against the contract addresses in the smart contract blacklist; and
in response to determining that the contract address of the target smart contract matches one of the contract addresses in the smart contract blacklist, determining that the target smart contract is a managed smart contract.

### Claim 33

A computer-implemented system, comprising:
one or more computers; and
one or more computer memory devices interoperably coupled with the one or more computers and having tangible, non-transitory, machine-readable media storing one or more instructions that, when executed by the one or more computers, perform one or more operations comprising:
in response to a first client device invoking a transaction with respect to a target smart contract, obtaining, by a blockchain node device in a blockchain, encrypted contract codes of the target smart contract, wherein the encrypted contract codes are stored in distributed ledgers of the blockchain, and wherein a trusted execution environment is installed on the blockchain node device;
transmitting the encrypted contract codes of the target smart contract to the trusted execution environment;
extracting a decryption key stored in the trusted execution environment, wherein the decryption key corresponds to the encrypted contract codes of the target smart contract;
decrypting the encrypted contract codes of the target smart contract using the extracted decryption key, to obtain decrypted contract codes;
executing the decrypted contract codes of the target smart contract in the trusted execution environment to obtain an execution result;
obtaining a smart contract management rule;
determining, in the trusted execution environment, that the target smart contract is a managed smart contract based on the smart contract management rule; and
in response to determining that the target smart contract is a managed smart contract, transmitting, to the first client device, a failure message.

### Claim 34 (depends on 33)

The computer-implemented system of claim 33, wherein the operations further comprise, in response to determining that the target smart contract is a managed smart contract, deleting the execution result.

### Claim 35 (depends on 33)

The computer-implemented system of claim 33, wherein the operations further comprise, in response to determining that the target smart contract is a managed smart contract:
storing the execution result in the trusted execution environment, and
setting the execution result stored in the trusted execution environment as extraction-prohibited.

### Claim 36 (depends on 33)

The computer-implemented system of claim 33, wherein the operations further comprise:
receiving creation transaction data corresponding to a creation transaction initiated by a second client device with respect to the target smart contract, wherein the creation transaction data comprises the encrypted contract codes of the target smart contract;
in response to receiving the creation transaction data, creating the target smart contract by executing smart contract creation codes in the trusted execution environment;
creating a contract account on the blockchain, wherein the contract account corresponds to the target smart contract; and
transmitting the encrypted contract codes of the target smart contract to the distributed ledgers of the blockchain for storage.

### Claim 37 (depends on 33)

The computer-implemented system of claim 33, wherein obtaining the smart contract management rule comprises:
monitoring, by the blockchain node device, data related to the target smart contract in an independent regulatory blockchain;
in response to a regulatory party generating a latest smart contract regulatory rule by invoking a second smart contract deployed on the independent regulatory blockchain, storing the latest smart contract regulatory rule into a local storage of the blockchain node device; and
reading, as the smart contract management rule, the latest smart contract regulatory rule from the local storage of the blockchain node device.

### Claim 38 (depends on 33)

The computer-implemented system of claim 33, herein the smart contract management rule comprises a smart contract blacklist comprising contract addresses of managed smart contracts, and
wherein determining that the target smart contract is a managed smart contract based on the smart contract management rule comprises:
obtaining a contract address of the target smart contract;
matching the contract address of the target smart contract against the contract addresses in the smart contract blacklist; and
in response to determining that the contract address of the target smart contract matches one of the contract addresses in the smart contract blacklist, determining that the target smart contract is a managed smart contract.
