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

NameService/ReverseLookupName - SUI

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

Resolves an address to its primary SuiNS name (if the address has set one). Used in wallets and explorers to display human-readable names instead of raw hex addresses.

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

Request Fields

Field
Type
Required
Description

address

Address

Yes

32-byte address (hex 0x...)

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 '{
    "address": "0xb871a42470b59c7184033a688f883cf24eb5e66eae1db62319bab27adb30b873"
}' \
  go.getblock.io:443/<ACCESS-TOKEN> \
  sui.rpc.v2.NameService/ReverseLookupName
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 = {
    "address": "0xb871a42470b59c7184033a688f883cf24eb5e66eae1db62319bab27adb30b873"
};

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

address

Address

Echoed address

name

string

Primary SuiNS name set by the address, or empty if no primary name is configured

Use Cases

  • Wallet UIs displaying example.sui instead of 0xb871a4...

  • Explorers showing primary names on address detail pages

  • Social features on top of Sui that surface usernames

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

Address has not set a primary SuiNS name

SDK Integration

Was this helpful?