LedgerService.GetObject
Get object through sui.rpc.v2.LedgerService/GetObject 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.LedgerService/GetObject. Unary: one request, one response. Get a key from the dashboard; the same key works on every protocol.
Request: GetObjectRequest
| Field | Type | Description |
|---|---|---|
object_id | string | Required. The ObjectId of the requested object. |
version | uint64 | Request a specific version of the object. If no version is specified, and the object is live, then the latest version of the object is returned. |
read_mask | google.protobuf.FieldMask | Mask specifying which fields to read. If no mask is specified, defaults to object_id,version,digest. |
Response: GetObjectResponse
| Field | Type | Description |
|---|---|---|
object | Object |
Object
An object on the Sui blockchain.
| Field | Type | Description |
|---|---|---|
bcs | Bcs | This Object serialized as BCS. |
object_id | string | ObjectId for this object. |
version | uint64 | Version of the object. |
digest | string | The digest of this Object. |
owner | Owner | Owner of the object. |
object_type | string | The type of this object. This will be 'package' for packages and a StructTag for move structs. |
has_public_transfer | bool | DEPRECATED this field is no longer used to determine whether a tx can transfer this object. Instead, it is always calculated from the objects type when loaded in execution. Only set for Move structs |
contents | Bcs | BCS bytes of a Move struct value. Only set for Move structs |
package | Package | Package information for Move Packages |
previous_transaction | string | The digest of the transaction that created or last mutated this object |
storage_rebate | uint64 | The amount of SUI to rebate if this object gets deleted. This number is re-calculated each time the object is mutated based on the present storage gas price. |
json | google.protobuf.Value | JSON rendering of the object. |
balance | uint64 | Current balance if this object is a 0x2::coin::Coin<T> |
display | Display | JSON rendering of the object based on an on-chain template. This will not be set if the value's type does not have an associated Display template. |
grpcurl
grpcurl -H "x-api-key: YOUR_API_KEY" \
-d '{
"object_id": "0x2",
"read_mask": {
"paths": [
"object_id",
"version",
"digest"
]
}
}' \
mainnet-grpc.inodra.com:443 \
sui.rpc.v2.LedgerService/GetObjectServer 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.ledgerService.getObject({
objectId: '0x2',
readMask: { paths: ['object_id', 'version', 'digest'] }
})
console.log(response.object)@mysten/sui v2 has no typed method for this RPC, so the sample calls the generated client.ledgerService 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. Reads served from the archival tier cost 2x; the response metadata carries x-inodra-backend naming the tier that answered. See credits and billing for the full table.
JSON-RPC equivalent
Replaces sui_getObject and sui_tryGetPastObject. The JSON-RPC to gRPC migration guide has before and after code for the common calls.
Related
- LedgerService overview and the gRPC gateway
- LedgerService.GetServiceInfo
- LedgerService.BatchGetObjects
- LedgerService.GetTransaction
- LedgerService.BatchGetTransactions
- LedgerService.GetCheckpoint
- LedgerService.GetEpoch
- LedgerService.ListCheckpoints
- LedgerService.ListTransactions
- LedgerService.ListEvents
- Proto definition on GitHub