GetDatatype - Sui
GetDatatype. Returns the layout of a Move struct or enum.
GetDatatype - sui [Value: 20CU]
Returns the layout of a Move struct or enum: abilities, type parameters, fields or variants.
gRPC: sui.rpc.v2.MovePackageService/GetDatatype
Use cases
- Decode object contents
- Generate typed bindings
- Check abilities of a type
Constraints
- Package, module and name required
- Uses the package storage id
Unlock Access to 100+ chains
Boost your app's speed and reliability with dRPC - get your access API key
Language
Request
Examples
grpcurl \
-H "x-drpc-key: {API-KEY}" \
-H "x-drpc-chain: sui" \
-d '{
"package_id": "0x2",
"module_name": "coin",
"name": "Coin"
}' \
grpc.drpc.live:443 \
sui.rpc.v2.MovePackageService/GetDatatypeResponse
200
{
"datatype": {
"type_name": "0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin",
"defining_id": "0x0000000000000000000000000000000000000000000000000000000000000002",
"module": "coin",
"name": "Coin",
"abilities": ["STORE", "KEY"],
"type_parameters": [ { "is_phantom": true } ],
"kind": "STRUCT",
"fields": [
{
"name": "id",
"position": 0,
"type": {
"type": "DATATYPE",
"type_name": "0x0000000000000000000000000000000000000000000000000000000000000002::object::UID"
}
},
{
"name": "balance",
"position": 1,
"type": {
"type": "DATATYPE",
"type_name": "0x0000000000000000000000000000000000000000000000000000000000000002::balance::Balance",
"type_parameter_instantiation": [ { "type": "TYPE_PARAMETER", "type_parameter": 0 } ]
}
}
]
}
}Request params
object
package_idstring
Required. Storage id of the package.
module_namestring
Required. Name of the module.
namestring
Required. Name of the datatype.
Response
200
Returns the layout of a Move struct or enum: abilities, type parameters, fields or variants.Response params
object
datatypeobject
The datatype descriptor.
object
type_namestring
Fully qualified name, `defining_id::module::name`.
defining_idstring
`storage_id` of the package version that first introduced the datatype.
modulestring
Module name.
namestring
Datatype name.
abilitiesarray_of_strings
Abilities: `COPY`, `DROP`, `STORE`, `KEY`.
type_parametersarray_of_objects
Generic type parameters: `constraints` and `is_phantom`.
kindstring
`STRUCT` or `ENUM`.
fieldsarray_of_objects
Fields of a struct: `name`, `position`, `type`.
variantsarray_of_objects
Variants of an enum: `name`, `position`, `fields`.