# US 11,307,990 B2 · Deploying a 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,307,990 B2
- Document ID: US11307990B2
- Status: Granted
- Kind: B2
- Application number: 17/322,444
- Filed: 2021-05-17
- Published: 2021-09-02
- Granted: 2022-04-19
- Earliest claimed: 2019-08-30
- Assignees: Advanced New Technologies Co., Ltd.
- Applicants: Advanced New Technologies Co., Ltd.
- Inventors: Zhongxiao Yao
- Web page: https://patentgrep.com/patent/US11307990B2

## CPC

- G06F 12/0875: with dedicated cache, e.g. instruction or stack
- H04L 9/3239: {involving non-keyed hash functions, e.g. modification detection codes [MDCs], MD5, SHA or RIPEMD}
- G06F 9/45504: {Abstract machines for program code execution, e.g. Java virtual machine [JVM], interpreters or emulators}
- G06F 12/04: Addressing variable-length words or parts of words
- G06F 16/2282: {Tablespace storage structures; Management thereof}
- G06F 16/2443: {Stored procedures}
- G06F 16/28: Databases characterised by their database models, e.g. relational or object models
- G06F 21/64: Protecting data integrity, e.g. using checksums, certificates or signatures
- H04L 9/50: {using hash chains, e.g. blockchains or hash trees}
- H04L 63/12: {Applying verification of the received information (cryptographic mechanisms or cryptographic arrangements for data integrity or data verification H04L9/32)}
- H04L 63/20: {for managing network security; network security policies in general (filtering policies H04L63/0227)}
- G06F 21/125: {by manipulating the program code, e.g. source code, compiled code, interpreted code, machine code}
- G06F 2212/452: Instruction code
- 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)

## Abstract

Implementations of the present specification provide a method for deploying a smart contract. According to one implementation the method includes: receiving a transaction request for invoking a first contract; obtaining a first instruction code and a function index table, wherein the function index table is used to indicate a memory address of an instruction code corresponding to each of import and export functions in the first contract; determining a first memory address corresponding to the invocation function based on the function index table; and executing the first instruction code in the first memory address based on the determined first memory address.

## Claims

### Claim 1

A computer-implemented method for executing a smart contract comprising:
receiving, by a node in a blockchain network, a transaction request for invoking a first contract, wherein the transaction request comprises a contract address and a function of the first contract;
obtaining, from a cache memory, a function index table that corresponds to the first contract and is stored in the cache memory after preprocessing the first contract during a phase of deploying the first contract, wherein the function index table is used to indicate at least a memory address of an instruction code corresponding to the function of the first contract;
identifying the memory address corresponding to the function based on the function index table; and
executing the function of the first contract based on the instruction code stored at the memory address.

### Claim 2 (depends on 1)

The computer-implemented method of claim 1, wherein the function index table comprises a first index table and a second index table, the first index table comprises a mapping relationship between a function name of each of one or more import and export functions in the first contract and one or more function index numbers, and the second index table comprises a mapping relationship between the one or more function index numbers and one or more memory addresses.

### Claim 3 (depends on 2)

The computer-implemented method of claim 2, wherein identifying the memory address corresponding to the function based on the function index table comprises:
searching the first index table based on a function name of the function to determine an index number corresponding to the function; and
searching the second index table by using the determined index number to determine a corresponding memory address as the memory address.

### Claim 4 (depends on 1)

The computer-implemented method of claim 1, wherein the function index table comprises a mapping relationship between a first function name and a first memory address.

### Claim 5 (depends on 1)

The computer-implemented method of claim 1, wherein the phase of deploying the first contract is completed prior to obtaining the function index table from the cache memory.

### Claim 6 (depends on 1)

The computer-implemented method of claim 1, wherein bytecode comprised in a contract module corresponding to the first contract is parsed into executable instruction code and used to determine the function index table stored in the cache memory prior to the node in the blockchain network receiving the transaction request for invoking the first contract.

### Claim 7 (depends on 6)

The computer-implemented method of claim 6, wherein the bytecode is encoded using a first coding protocol.

### Claim 8 (depends on 7)

The computer-implemented method of claim 7, wherein the first coding protocol is a variable-length coding protocol.

### Claim 9 (depends on 7)

The computer-implemented method of claim 7, wherein the first contract is parsed into the executable instruction code using a decoding protocol corresponding to the first coding protocol.

### Claim 10 (depends on 7)

The computer-implemented method of claim 7, wherein a variable-length instruction is converted into a memory-aligned fixed-length instruction.

### Claim 11 (depends on 7)

The computer-implemented method of claim 7, wherein the contract module is a WebAssembly (WASM) module, and the first coding protocol is a leb 128 coding protocol.

### Claim 12 (depends on 6)

The computer-implemented method of claim 6, wherein the bytecode is parsed into the executable instruction code using a memory-aligned instruction storage location to modify a target address in a control transfer instruction.

### Claim 13

A non-transitory, computer-readable medium storing one or more instructions executable by a computer system to perform operations for executing a smart contract comprising:
receiving, by a node in a blockchain network, a transaction request for invoking a first contract, wherein the transaction request comprises a contract address and a function of the first contract;
obtaining, from a cache memory, a function index table that corresponds to the first contract and is stored in the cache memory after preprocessing the first contract during a phase of deploying the first contract, wherein the function index table is used to indicate at least a memory address of an instruction code corresponding to the function of the first contract;
identifying the memory address corresponding to the function based on the function index table; and
executing the function of the first contract based on the instruction code stored at the memory address.

### Claim 14 (depends on 13)

The non-transitory, computer-readable medium of claim 13, wherein the function index table comprises a first index table and a second index table, the first index table comprises a mapping relationship between a function name of each of one or more import and export functions in the first contract and one or more function index numbers, and the second index table comprises a mapping relationship between the one or more function index numbers and one or more memory addresses.

### Claim 15 (depends on 14)

The non-transitory, computer-readable medium of claim 14, wherein identifying the memory address corresponding to the function based on the function index table comprises:
searching the first index table based on a function name of the function to determine an index number corresponding to the function; and
searching the second index table by using the determined index number to determine a corresponding memory address as the memory address.

### Claim 16 (depends on 13)

The non-transitory, computer-readable medium of claim 13, wherein the function index table comprises a mapping relationship between a first function name and a first memory address.

### Claim 17 (depends on 13)

The non-transitory, computer-readable medium of claim 13, wherein the phase of deploying the first contract is completed prior to obtaining the function index table from the cache memory.

### Claim 18

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 for executing a smart contract, wherein the operations comprise:
receiving, by a node in a blockchain network, a transaction request for invoking a first contract, wherein the transaction request comprises a contract address and a function of the first contract;
obtaining, from a cache memory, a function index table that corresponds to the first contract and is stored in the cache memory after preprocessing the first contract during a phase of deploying the first contract, wherein the function index table is used to indicate at least a memory address of an instruction code corresponding to the function of the first contract;
identifying the memory address corresponding to the function based on the function index table; and
executing the function of the first contract based on the instruction code stored at the memory address.

### Claim 19 (depends on 18)

The computer-implemented system of claim 18, wherein the function index table comprises a first index table and a second index table, the first index table comprises a mapping relationship between a function name of each of one or more import and export functions in the first contract and one or more function index numbers, and the second index table comprises a mapping relationship between the one or more function index numbers and one or more memory addresses.

### Claim 20 (depends on 18)

The computer-implemented system of claim 18, wherein the phase of deploying the first contract is completed prior to obtaining the function index table from the cache memory.
