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
Parameter | Type | Required | Description |
---|---|---|---|
objectId | string | Yes | The unique identifier of the object (64-character hex string with 0x prefix) |
options | object | No | Options for controlling the response content |
Options Object
Field | Type | Default | Description |
---|---|---|---|
showType | boolean | false | Include the object's Move type information |
showOwner | boolean | false | Include object ownership details |
showPreviousTransaction | boolean | false | Include the previous transaction digest |
showDisplay | boolean | false | Include display metadata if available |
showContent | boolean | false | Include the object's content fields |
showBcs | boolean | false | Include BCS-encoded object data |
showStorageRebate | boolean | false | Include storage rebate information |
Returns
Returns an object containing the requested information about the Sui object.
Field | Type | Description |
---|---|---|
data | object | The object's data including content and metadata |
error | object | Error information if the object doesn't exist |
Object Data Structure
Field | Type | Description |
---|---|---|
objectId | string | Unique identifier of the object |
version | string | Current version/sequence number |
digest | string | Object content digest |
type | string | Move type of the object (if requested) |
owner | object | Ownership information (if requested) |
previousTransaction | string | Previous transaction digest (if requested) |
storageRebate | string | Storage rebate amount (if requested) |
display | object | Display metadata (if requested) |
content | object | Object's fields and values (if requested) |
bcs | object | BCS-encoded data (if requested) |
Code Examples
- cURL
- JavaScript
- Python
curl -X POST https://api-sui-mainnet-full.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "sui_getObject",
"params": [
"0xc3452f5ef4b99c35d7c05b4beddeaf35513c9c6f61a6e519dcde009a8bde0a60",
{
"showType": true,
"showOwner": true,
"showPreviousTransaction": true,
"showDisplay": false,
"showContent": true,
"showBcs": false,
"showStorageRebate": true
}
],
"id": 1
}'
const response = await fetch('https://api-sui-mainnet-full.n.dwellir.com/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'sui_getObject',
params: [
'0xc3452f5ef4b99c35d7c05b4beddeaf35513c9c6f61a6e519dcde009a8bde0a60',
{
showType: true,
showOwner: true,
showPreviousTransaction: true,
showContent: true,
showStorageRebate: true
}
],
id: 1
})
});
const data = await response.json();
if (data.result?.data) {
console.log('Object ID:', data.result.data.objectId);
console.log('Version:', data.result.data.version);
console.log('Type:', data.result.data.type);
console.log('Owner:', data.result.data.owner);
console.log('Content:', data.result.data.content);
} else if (data.result?.error) {
console.error('Object not found:', data.result.error);
}
import requests
import json
url = 'https://api-sui-mainnet-full.n.dwellir.com/YOUR_API_KEY'
headers = {'Content-Type': 'application/json'}
payload = {
"jsonrpc": "2.0",
"method": "sui_getObject",
"params": [
"0xc3452f5ef4b99c35d7c05b4beddeaf35513c9c6f61a6e519dcde009a8bde0a60",
{
"showType": True,
"showOwner": True,
"showPreviousTransaction": True,
"showContent": True,
"showStorageRebate": True
}
],
"id": 1
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
result = response.json()
if 'data' in result.get('result', {}):
object_data = result['result']['data']
print(f"Object ID: {object_data['objectId']}")
print(f"Version: {object_data['version']}")
print(f"Type: {object_data.get('type', 'N/A')}")
print(f"Owner: {object_data.get('owner', 'N/A')}")
elif 'error' in result.get('result', {}):
print(f"Error: {result['result']['error']}")
Response Example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"data": {
"objectId": "0xc3452f5ef4b99c35d7c05b4beddeaf35513c9c6f61a6e519dcde009a8bde0a60",
"version": "639710666",
"digest": "GoM8ef5MCLDj4C5wG2e7fikQxbzw1HRpMqF8TMqQoEhU",
"type": "0xb7c36a747d6fdd6b59ab0354cea52a31df078c242242465a867481b6f4509498::artipedia::AdminRegistry",
"owner": {
"Shared": {
"initial_shared_version": 589165847
}
},
"previousTransaction": "Cj46h84RuRyPwMTsz9ZnwEgUSZrBN2y5CWVs8ybmo7xF",
"storageRebate": "21857600",
"content": {
"dataType": "moveObject",
"type": "0xb7c36a747d6fdd6b59ab0354cea52a31df078c242242465a867481b6f4509498::artipedia::AdminRegistry",
"hasPublicTransfer": false,
"fields": {
"admins": {
"type": "0x2::vec_set::VecSet<address>",
"fields": {
"contents": [
"0x9470585d9b80a03d6e86a4615d5a51e9c687cfa0bd1cd162fe8184e89be77087",
"0xc0aa3e74608619357d620274e67f6bd5ff3686ce057698461aa14e6524b152ff",
"0x9eb46f5d18a825c7e1f3de854b1ccf55b01560fafea04d9d23e6d95847105f36",
"0x98d18307d82241175667c039c994e8e38dd6ef6999a7204c9cbcc5cf71ffb367",
...
]
}
},
"id": {
"id": "0xc3452f5ef4b99c35d7c05b4beddeaf35513c9c6f61a6e519dcde009a8bde0a60"
},
"treasury_cap": {
"type": "0x2::coin::TreasuryCap<0xb7c36a747d6fdd6b59ab0354cea52a31df078c242242465a867481b6f4509498::artipedia::ARTIPEDIA>",
"fields": {
"id": {
"id": "0xe02bfd2c4ddbee1c4ea44ed30cd45739e35d5f4b9917f59f93ee78c53cb03cec"
},
"total_supply": {
"type": "0x2::balance::Supply<0xb7c36a747d6fdd6b59ab0354cea52a31df078c242242465a867481b6f4509498::artipedia::ARTIPEDIA>",
"fields": {
"value": "2610479803989323936"
}
}
}
}
}
}
}
}
}
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
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.