sui_getObject{deprecated} - Sui

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.

This method is deprecated

Parameters

ParameterTypeRequiredDescriptionDefault/Supported Values
object_idstringYesThe unique identifier of the object to queryMust be a valid SUI object ID (0x prefixed)
optionsobjectNoOptions specifying which data to includeSee ObjectDataOptions below

ObjectDataOptions

FieldTypeDefaultDescription
showTypebooleanfalseInclude the object's type information
showOwnerbooleanfalseInclude owner information
showPreviousTransactionbooleanfalseInclude the digest of the last modifying transaction
showDisplaybooleanfalseInclude display fields for NFTs
showContentbooleanfalseInclude the object's Move content
showBcsbooleanfalseInclude BCS-encoded content
showStorageRebatebooleanfalseInclude storage rebate information

Request Example

cURL

bashcurl --location --request POST https://shared.eu-central-1.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"
}'

Python

pythonimport requests
import json

url = "https://shared.eu-central-1.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)

JavaScript (Axios)

javascriptconst axios = require('axios');

const url = "https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/";
const payload = {
  jsonrpc: "2.0",
  method: "sui_getObject",
  params: [
    "0x53e4567ccafa5f36ce84c80aa8bc9be64e0d5ae796884274aef3005ae6733809",
    {
      showType: true,
      showOwner: true,
      showContent: true
    }
  ],
  id: "getblock.io"
};

axios.post(url, payload, {
  headers: { "Content-Type": "application/json" }
})
.then(response => {
  console.log("Result:", response.data.result);
})
.catch(error => {
  console.error("Error:", error.response?.status, error.response?.data);
});

Rust

rustuse reqwest::Client;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();
    
    let payload = json!({
        "jsonrpc": "2.0",
        "id": "getblock.io",
        "method": "sui_getObject",
        "params": [
            "0x53e4567ccafa5f36ce84c80aa8bc9be64e0d5ae796884274aef3005ae6733809",
            {
                "showType": true,
                "showOwner": true,
                "showContent": true
            }
        ]
    });

    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header("Content-Type", "application/json")
        .json(&payload)
        .send()
        .await?;

    println!("Response: {:?}", response.text().await?);
    Ok(())
}

Response

json{
  "jsonrpc": "2.0",
  "id": "getblock.io",
  "result": {
    "data": {
      "objectId": "0x53e4567ccafa5f36ce84c80aa8bc9be64e0d5ae796884274aef3005ae6733809",
      "version": "1",
      "digest": "33K5ZXJ3RyubvYaHuEnQ1QXmmbhgtrFwp199dnEbL4n7",
      "type": "0x2::coin::Coin<0x2::sui::SUI>",
      "owner": {
        "AddressOwner": "0xc8ec1d5b84dd6289e193b9f88de4a994358c9f856135236c3e75a925e1c77ac3"
      },
      "previousTransaction": "5PLgmQye6rraDYqpV3npV6H1cUXoJZgJh1dPCyRa3WCv",
      "storageRebate": "100",
      "content": {
        "dataType": "moveObject",
        "type": "0x2::coin::Coin<0x2::sui::SUI>",
        "hasPublicTransfer": true,
        "fields": {
          "balance": "100000000",
          "id": {
            "id": "0x53e4567ccafa5f36ce84c80aa8bc9be64e0d5ae796884274aef3005ae6733809"
          }
        }
      }
    }
  }
}

Response Parameters

ParameterTypeDescription
jsonrpcstringThe JSON-RPC protocol version ("2.0")
idstringRequest identifier
result.dataobjectThe object data if found
result.data.objectIdstringUnique object identifier
result.data.versionstringObject version number
result.data.digeststringObject digest hash
result.data.typestringFully qualified Move type
result.data.ownerobjectOwner information (AddressOwner, ObjectOwner, Shared, or Immutable)
result.data.previousTransactionstringDigest of last modifying transaction
result.data.storageRebatestringStorage rebate in MIST
result.data.contentobjectObject content including Move fields

Use Cases

  1. NFT Metadata Retrieval: Fetch NFT metadata, display fields, and ownership information for marketplace applications or NFT galleries by querying the object with showDisplay and showContent options.
  2. Object Ownership Verification: Verify object ownership before initiating transactions by checking the owner field, essential for security validations in dApps.
  3. Smart Contract State Inspection: Inspect the state of smart contract instances by retrieving their Move content, enabling debugging and state verification.

Error handling

CodeDescriptionSolution
Invalid Object IDThe object ID is not properly formattedEnsure the ID is a valid 66-character hexadecimal string
NotExistsObject does not exist on-chainVerify the object ID is correct and exists
DeletedObject has been deletedThe object was consumed or deleted in a transaction
UnknownVersionRequested version not foundUse sui_tryGetPastObject for historical versions

SDK Integration

SUI TypeScript SDK

typescriptimport { SuiClient } from '@mysten/sui/client';

const client = new SuiClient({ url: 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' });

const object = await client.getObject({
  id: '0x53e4567ccafa5f36ce84c80aa8bc9be64e0d5ae796884274aef3005ae6733809',
  options: {
    showType: true,
    showOwner: true,
    showContent: true,
  },
});

console.log(object);

SUI Rust SDK

rustuse sui_sdk::SuiClientBuilder;
use sui_sdk::types::base_types::ObjectID;

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
    let sui = SuiClientBuilder::default()
        .build("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .await?;
    
    let object_id: ObjectID = "0x53e4567ccafa5f36ce84c80aa8bc9be64e0d5ae796884274aef3005ae6733809".parse()?;
    let object = sui.read_api().get_object_with_options(object_id, None).await?;
    
    println!("{:?}", object);
    Ok(())
}