MovePackageService.GetDatatype
Get datatype through sui.rpc.v2.MovePackageService/GetDatatype on Inodra's Sui gRPC endpoint.
Endpoint
| Network | Host | Authentication |
|---|---|---|
| Mainnet | mainnet-grpc.inodra.com:443 | x-api-key metadata |
| Testnet | testnet-grpc.inodra.com:443 | x-api-key metadata |
Full method name: sui.rpc.v2.MovePackageService/GetDatatype. Unary: one request, one response. Get a key from the dashboard; the same key works on every protocol.
Request: GetDatatypeRequest
| Field | Type | Description |
|---|---|---|
package_id | string | Required. The storage_id of the requested package. |
module_name | string | Required. The name of the requested module. |
name | string | Required. The name of the requested datatype. |
Response: GetDatatypeResponse
| Field | Type | Description |
|---|---|---|
datatype | DatatypeDescriptor | The datatype. |
DatatypeDescriptor
Describes a Move Datatype.
| Field | Type | Description |
|---|---|---|
type_name | string | Fully qualified name of this Datatype. This is <defining_id>::<module>::<name> |
defining_id | string | PackageId of the package where this Datatype is defined. A type's defining_id is the storage_id of the package version that first introduced or added that type. |
module | string | Name of the module where this Datatype is defined |
name | string | Name of this Datatype |
abilities | repeated Ability | This type's abilities |
type_parameters | repeated TypeParameter | Ability constraints and phantom status for this type's generic type parameters |
kind | DatatypeDescriptor.DatatypeKind | Indicates whether this datatype is a 'STRUCT' or an 'ENUM' |
fields | repeated FieldDescriptor | Set of fields if this Datatype is a struct. The order of the entries is the order of how the fields are defined. |
variants | repeated VariantDescriptor | Set of variants if this Datatype is an enum. The order of the entries is the order of how the variants are defined. |
grpcurl
grpcurl -H "x-api-key: YOUR_API_KEY" \
-d '{
"package_id": "0x2",
"module_name": "coin",
"name": "Coin"
}' \
mainnet-grpc.inodra.com:443 \
sui.rpc.v2.MovePackageService/GetDatatypeServer reflection is enabled, so no proto files are needed for grpcurl. Field masks are written as {"paths": [...]}.
TypeScript
import { GrpcWebFetchTransport, SuiGrpcClient } from '@mysten/sui/grpc'
const transport = new GrpcWebFetchTransport({
baseUrl: 'https://mainnet-grpc.inodra.com',
meta: { 'x-api-key': process.env.INODRA_API_KEY! }
})
const client = new SuiGrpcClient({ network: 'mainnet', transport })
const { response } = await client.movePackageService.getDatatype({
packageId: '0x2',
moduleName: 'coin',
name: 'Coin'
})
console.log(response.datatype)@mysten/sui v2 has no typed method for this RPC, so the sample calls the generated client.movePackageService service client. Install with npm install @mysten/sui and set INODRA_API_KEY. The gRPC gateway guide covers native gRPC transport for backends.
Credits
1 credit per call. See credits and billing for the full table.
JSON-RPC equivalent
Replaces sui_getNormalizedMoveStruct. The JSON-RPC to gRPC migration guide has before and after code for the common calls.