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

Parameter
Type
Required
Description
Default/Supported Values

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

Field
Type
Default
Description

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
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"
}'

Response

Response Parameters

Parameter
Type
Description

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

  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

Code
Description
Solution

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?