Skip to main content

sui_getObject

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.

Parameters​

ParameterTypeRequiredDescription
objectIdstringYesThe unique identifier of the object (64-character hex string with 0x prefix)
optionsobjectNoOptions for controlling the response content

Options Object​

FieldTypeDefaultDescription
showTypebooleanfalseInclude the object's Move type information
showOwnerbooleanfalseInclude object ownership details
showPreviousTransactionbooleanfalseInclude the previous transaction digest
showDisplaybooleanfalseInclude display metadata if available
showContentbooleanfalseInclude the object's content fields
showBcsbooleanfalseInclude BCS-encoded object data
showStorageRebatebooleanfalseInclude storage rebate information

Returns​

Returns an object containing the requested information about the Sui object.

FieldTypeDescription
dataobjectThe object's data including content and metadata
errorobjectError information if the object doesn't exist

Object Data Structure​

FieldTypeDescription
objectIdstringUnique identifier of the object
versionstringCurrent version/sequence number
digeststringObject content digest
typestringMove type of the object (if requested)
ownerobjectOwnership information (if requested)
previousTransactionstringPrevious transaction digest (if requested)
storageRebatestringStorage rebate amount (if requested)
displayobjectDisplay metadata (if requested)
contentobjectObject's fields and values (if requested)
bcsobjectBCS-encoded data (if requested)

Code Examples​

curl -X POST https://sui-mainnet.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "sui_getObject",
"params": [
"0x5d3c87e88bc566e3f10c66e0275a366001ffa8b86142adc78c744de6afffeb34",
{
"showType": true,
"showOwner": true,
"showPreviousTransaction": true,
"showDisplay": false,
"showContent": true,
"showBcs": false,
"showStorageRebate": true
}
],
"id": 1
}'

Response Example​

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"data": {
"objectId": "0x5d3c87e88bc566e3f10c66e0275a366001ffa8b86142adc78c744de6afffeb34",
"version": "31823924",
"digest": "HpSeCiMLG53N9FcHDrRTxwGhc4RVJa1seZhXYJ7KFpJe",
"type": "0x2::coin::Coin<0x2::sui::SUI>",
"owner": {
"AddressOwner": "0xd77955e670601c2c2e6e8637e383695c166aac0a86b741c266bdfb23c2e3369f"
},
"previousTransaction": "C2QKmxrYPNBJjNmLtZrzFt9tVfq7wo2JZBmc5nQKYFdt",
"storageRebate": "988000",
"content": {
"dataType": "moveObject",
"type": "0x2::coin::Coin<0x2::sui::SUI>",
"hasPublicTransfer": true,
"fields": {
"balance": "1000000000",
"id": {
"id": "0x5d3c87e88bc566e3f10c66e0275a366001ffa8b86142adc78c744de6afffeb34"
}
}
}
}
}
}

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);
}

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 digest field 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.