For the complete documentation index, see llms.txt. This page is also available as Markdown.

MovePackageService/GetPackage - SUI

Example code for the MovePackageService/GetPackage gRPC method. Complete guide on how to use MovePackageService/GetPackage gRPC method in GetBlock Web3 documentation.

Returns metadata for a Move package — the modules it contains, their dependencies, and the package version. Move packages on Sui are upgradeable; this method returns the package at its current latest version unless version is specified.

Service: sui.rpc.v2.MovePackageService Proto file: sui/rpc/v2/move_package_service.proto Full method path: sui.rpc.v2.MovePackageService/GetPackage

Request Fields

Field
Type
Required
Description

package_id

ObjectId

Yes

32-byte ID of the package

version

uint64

No

Specific package version; omit for the latest

read_mask

FieldMask

No

Field paths to include

Request Example

# Clone the official proto files first (one-time setup):
#   git clone https://github.com/MystenLabs/sui-apis.git && cd sui-apis

grpcurl \
  -import-path proto \
  -proto sui/rpc/v2/move_package_service.proto \
  -H "x-grpc-web: 1" \
  -d '{
    "package_id": "0x0000000000000000000000000000000000000000000000000000000000000002",
    "read_mask": {
        "paths": [
            "*"
        ]
    }
}' \
  go.getblock.io:443/<ACCESS-TOKEN> \
  sui.rpc.v2.MovePackageService/GetPackage
import * as grpc from '@grpc/grpc-js';
import * as protoLoader from '@grpc/proto-loader';
import * as path from 'path';

const PROTO_PATH = path.join(__dirname, 'protos/proto/sui/rpc/v2/move_package_service.proto');
const ACCESS_TOKEN = '<ACCESS-TOKEN>';

const packageDef = protoLoader.loadSync(PROTO_PATH, {
    includeDirs: [path.join(__dirname, 'protos/proto')],
    keepCase: true, longs: String, enums: String, defaults: true,
});
const proto = grpc.loadPackageDefinition(packageDef) as any;
const ServiceClient = proto.sui.rpc.v2.MovePackageService;

const metadata = new grpc.Metadata();
metadata.add('authorization', `Bearer ${ACCESS_TOKEN}`);

const client = new ServiceClient('go.getblock.io:443', grpc.credentials.createSsl());

const request = {
    "package_id": "0x0000000000000000000000000000000000000000000000000000000000000002",
    "read_mask": {
        "paths": [
            "*"
        ]
    }
};

client.GetPackage(request, metadata, (err: any, response: any) => {
    if (err) {
        console.error('Error:', err);
        return;
    }
    console.log(JSON.stringify(response, null, 2));
});

Response Example

Responses are encoded in Protocol Buffers binary format on the wire. The example below shows the protobuf JSON encoding for readability.

Response Fields

Field
Type
Description

package.package_id

ObjectId

Echoed package ID

package.version

string

Package version

package.modules

repeated Module

Modules contained in the package

package.modules[].name

string

Module name

package.modules[].type_count

uint32

Number of types defined in this module

package.modules[].function_count

uint32

Number of functions defined in this module

package.type_origin_table

repeated TypeOrigin

Maps types to their originating modules (for upgrades)

package.linkage_table

repeated Linkage

External package dependencies

Use Cases

  • Move IDE / tooling introspection

  • Building Move package explorers

  • Detecting package upgrades

  • Static analysis pipelines

Error Handling

gRPC uses status codes rather than JSON-RPC numeric error codes. The most relevant for this method:

Status Code
Numeric
Cause

UNAUTHENTICATED

16

Missing or invalid <ACCESS-TOKEN> in the URL path

INVALID_ARGUMENT

3

Request fields are missing, malformed, or fail validation

UNAVAILABLE

14

Node is overloaded or temporarily unable to handle the request — retry with backoff

DEADLINE_EXCEEDED

4

Request did not complete within the timeout window

RESOURCE_EXHAUSTED

8

Rate limit exceeded for your plan

NOT_FOUND

5

No package exists at the requested ID, or the requested version doesn't exist

SDK Integration

Was this helpful?