sui_getObject - Sui
Example code for the sui_getObject JSON-RPC method. Complete guide on how to use sui_getObject JSON-RPC in GetBlock Web3 documentation.
This method retrieves comprehensive information about a specified object on the SUI network, including its type, owner, content, version history, and storage details based on configurable options.
Parameters
object_id
string
Yes
The unique identifier of the object to query
Must be a valid SUI object ID (0x prefixed)
options
object
No
Options specifying which data to include
See ObjectDataOptions below
ObjectDataOptions
showType
boolean
false
Include the object's type information
showOwner
boolean
false
Include owner information
showPreviousTransaction
boolean
false
Include the digest of the last modifying transaction
showDisplay
boolean
false
Include display fields for NFTs
showContent
boolean
false
Include the object's Move content
showBcs
boolean
false
Include BCS-encoded content
showStorageRebate
boolean
false
Include storage rebate information
Request Example
curl --location --request POST https://go.getblock.io/<ACCESS-TOKEN>/ \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "sui_getObject",
"params": [
"0x53e4567ccafa5f36ce84c80aa8bc9be64e0d5ae796884274aef3005ae6733809",
{
"showType": true,
"showOwner": true,
"showPreviousTransaction": true,
"showContent": true,
"showStorageRebate": true
}
],
"id": "getblock.io"
}'import requests
import json
url = "https://go.getblock.io/<ACCESS-TOKEN>/"
headers = {"Content-Type": "application/json"}
payload = {
"jsonrpc": "2.0",
"method": "sui_getObject",
"params": [
"0x53e4567ccafa5f36ce84c80aa8bc9be64e0d5ae796884274aef3005ae6733809",
{
"showType": True,
"showOwner": True,
"showContent": True
}
],
"id": "getblock.io"
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
if response.status_code == 200:
print("Result:", response.json().get("result"))
else:
print("Error:", response.status_code, response.text)Response
Response Parameters
jsonrpc
string
The JSON-RPC protocol version ("2.0")
id
string
Request identifier
result.data
object
The object data if found
result.data.objectId
string
Unique object identifier
result.data.version
string
Object version number
result.data.digest
string
Object digest hash
result.data.type
string
Fully qualified Move type
result.data.owner
object
Owner information (AddressOwner, ObjectOwner, Shared, or Immutable)
result.data.previousTransaction
string
Digest of last modifying transaction
result.data.storageRebate
string
Storage rebate in MIST
result.data.content
object
Object content including Move fields
Use Cases
NFT Metadata Retrieval: Fetch NFT metadata, display fields, and ownership information for marketplace applications or NFT galleries by querying the object with
showDisplayandshowContentoptions.Object Ownership Verification: Verify object ownership before initiating transactions by checking the owner field, essential for security validations in dApps.
Smart Contract State Inspection: Inspect the state of smart contract instances by retrieving their Move content, enabling debugging and state verification.
Error handling
Invalid Object ID
The object ID is not properly formatted
Ensure the ID is a valid 66-character hexadecimal string
NotExists
Object does not exist on-chain
Verify the object ID is correct and exists
Deleted
Object has been deleted
The object was consumed or deleted in a transaction
UnknownVersion
Requested version not found
Use sui_tryGetPastObject for historical versions
SDK Integration
Last updated
Was this helpful?