sui_getObject - Retrieve Sui Object Data
Query object information on Sui blockchain using sui_getObject RPC method. Access object data, ownership, version, and content with Dwellir's high-performance Sui infrastructure.
Retrieves comprehensive information about an object on the Sui blockchain, including its data, ownership, version, and type information.
Overview
The sui_getObject method is fundamental to interacting with Sui's object-centric architecture. Every piece of data on Sui is represented as an object with a unique identifier, and this method allows you to query any object's current state, ownership information, and associated metadata.
Code Examples
Common Use Cases
1. Querying Coin Objects
// Get SUI coin object with balance
const coinObject = await provider.getObject({
id: coinObjectId,
options: {
showType: true,
showContent: true,
showOwner: true
}
});
const balance = coinObject.data?.content?.fields?.balance;
console.log(`Coin balance: ${balance}`);2. Retrieving NFT Metadata
// Get NFT with display information
const nftObject = await provider.getObject({
id: nftObjectId,
options: {
showDisplay: true,
showContent: true,
showOwner: true
}
});
const display = nftObject.data?.display?.data;
console.log(`NFT Name: ${display?.name}`);
console.log(`Image URL: ${display?.image_url}`);3. Checking Object Ownership
// Verify object ownership
const object = await provider.getObject({
id: objectId,
options: { showOwner: true }
});
const owner = object.data?.owner;
if (owner?.AddressOwner === userAddress) {
console.log('User owns this object');
} else if (owner?.Shared) {
console.log('This is a shared object');
} else if (owner?.Immutable) {
console.log('This is an immutable object');
}Object Ownership Types
Sui supports different ownership models that affect how objects can be accessed and modified:
Address-Owned Objects
- Owner: Single address
- Access: Only the owner can modify
- Consensus: Fast-path execution without full consensus
Shared Objects
- Owner: Accessible by anyone
- Access: Multiple transactions can access simultaneously
- Consensus: Requires full consensus
Immutable Objects
- Owner: No owner (read-only)
- Access: Anyone can read, no one can modify
- Consensus: No consensus needed for reads
Object-Owned Objects
- Owner: Another object
- Access: Through parent object transactions
- Consensus: Depends on parent object's ownership
Best Practices
Optimize Request Options
Only request the data fields you need to minimize response size and improve performance:
// Minimal request for checking existence
const exists = await provider.getObject({
id: objectId,
options: {} // No additional data requested
});
// Full request for detailed analysis
const detailed = await provider.getObject({
id: objectId,
options: {
showType: true,
showOwner: true,
showContent: true,
showPreviousTransaction: true
}
});Handle Different Object Types
function parseObjectType(typeString) {
// Example: "0x2::coin::Coin<0x2::sui::SUI>"
const match = typeString.match(/^([^<]+)(?:<(.+)>)?$/);
return {
module: match?.[1],
typeParam: match?.[2]
};
}Error Handling
try {
const result = await provider.getObject({ id: objectId });
if (result.error) {
switch (result.error.code) {
case 'objectNotFound':
console.log('Object does not exist');
break;
case 'objectDeleted':
console.log('Object has been deleted');
break;
default:
console.error('Unknown error:', result.error);
}
} else {
// Process object data
processObject(result.data);
}
} catch (error) {
console.error('RPC error:', error);
}Related Methods
- sui_executeTransactionBlock - Execute transactions on objects
- suix_getBalance - Query coin balances
Notes
- Object IDs are unique and immutable across the entire Sui network
- Object versions increment with each modification
- Deleted objects return an error but their ID remains reserved
- The
digestfield provides a hash of the object's content for verification - Storage rebates are refunded when objects are deleted
Need help? Contact our support team or check the Sui documentation.
sui_getCheckpoint - Get Checkpoint Info
Get detailed checkpoint information from Sui blockchain including transactions, network metrics, and consensus data using Dwellir's high-performance Sui RPC infrastructure.
sui_getTransactionBlock - Get Executed T...
Get comprehensive transaction details on Sui blockchain using sui_getTransactionBlock RPC method. Access transaction data, effects, events, and execution results with Dwellir's high-performance Sui infrastructure.