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

NameService/LookupName - SUI

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

Resolves a SuiNS name (e.g. example.sui) to its associated 32-byte address. SuiNS is Sui's native name service.

Service: sui.rpc.v2.NameService Proto file: sui/rpc/v2/name_service.proto Full method path: sui.rpc.v2.NameService/LookupName

Request Fields

Field
Type
Required
Description

name

string

Yes

SuiNS name — typically ends with .sui

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/name_service.proto \
  -H "x-grpc-web: 1" \
  -d '{
    "name": "example.sui"
}' \
  go.getblock.io:443/<ACCESS-TOKEN> \
  sui.rpc.v2.NameService/LookupName
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/name_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.NameService;

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

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

const request = {
    "name": "example.sui"
};

client.LookupName(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

name

string

Echoed name

address

Address

Resolved 32-byte address

expiration_timestamp_ms

string

Unix-millis timestamp when the registration expires

Use Cases

  • Wallet UIs accepting example.sui instead of 0x... for transfers

  • Address book features in wallets

  • Identity layers on top of Sui

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

Name is not registered or has expired

SDK Integration

Was this helpful?