suix_getCoins - Sui

Example code for the suix_getCoins JSON-RPC method. Complete guide on how to use suix_getCoins JSON-RPC in GetBlock Web3 documentation.

This method returns all Coin objects of a specific type owned by an address on the SUI network. This filtered version of suix_getAllCoins is more efficient when you only need coins of a particular type, such as SUI for gas payments or a specific token for transfers. It supports pagination for addresses with many coin objects.

Parameters

Parameter
Type
Required
Description

owner

SuiAddress

Yes

The owner's SUI address (0x prefixed hex string)

coin_type

string

No

Type name for the coin (defaults to 0x2::sui::SUI)

cursor

string

No

Optional paging cursor for pagination

limit

uint

No

Maximum number of items per page

Returns

Field
Type
Description

data

array

Array of Coin objects matching the specified type

nextCursor

string

Cursor for fetching the next page

hasNextPage

boolean

Indicates if more results are available

Request Example

curl
curl -X POST https://go.getblock.io/<ACCESS-TOKEN>/ \
-H "Content-Type: application/json" \
-d '{
  "jsonrpc": "2.0",
  "id": "getblock.io",
  "method": "suix_getCoins",
  "params": [
    "0x94f1a597b4e8f709a396f7f6b1482bdcd65a673d111e49286c527fab7c2d0961",
    "0x2::sui::SUI",
    null,
    10
  ]
}'

Response Example

Response Parameters

Parameter
Type
Description

coinType

string

The fully qualified coin type

coinObjectId

string

Unique identifier of the coin object

version

string

Current version number of the object

digest

string

Object digest hash

balance

string

Balance in the coin's smallest unit

previousTransaction

string

Last transaction that modified this object

nextCursor

string

Cursor for next page

hasNextPage

boolean

True if more results exist

Use Cases

  • Select SUI coins for gas payment in transactions

  • Find specific token coins for transfer operations

  • Implement efficient coin selection for payments

  • List all coins of a custom token type

  • Prepare inputs for Programmable Transaction Blocks

Error Handling

Error Code
Description

-32602

Invalid params - malformed address or coin type

-32603

Internal error - node processing issues

-32000

Server error - RPC endpoint unavailable

SDK Integration

Last updated

Was this helpful?