suix_getCoins{deprecated} - Sui

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.

This method is deprecated

Parameters

ParameterTypeRequiredDescription
ownerSuiAddressYesThe owner's SUI address (0x prefixed hex string)
coin_typestringNoType name for the coin (defaults to 0x2::sui::SUI)
cursorstringNoOptional paging cursor for pagination
limituintNoMaximum number of items per page

Returns

FieldTypeDescription
dataarrayArray of Coin objects matching the specified type
nextCursorstringCursor for fetching the next page
hasNextPagebooleanIndicates if more results are available

Request Example

curl

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

request.js

javascriptconst axios = require('axios');

const url = 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/';

const payload = {
  jsonrpc: '2.0',
  id: 'getblock.io',
  method: 'suix_getCoins',
  params: [
    '0x94f1a597b4e8f709a396f7f6b1482bdcd65a673d111e49286c527fab7c2d0961',
    '0x2::sui::SUI',
    null,
    10
  ]
};

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

request.py

pythonimport requests
import json

url = "https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/"

payload = {
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "method": "suix_getCoins",
    "params": [
        "0x94f1a597b4e8f709a396f7f6b1482bdcd65a673d111e49286c527fab7c2d0961",
        "0x2::sui::SUI",
        None,
        10
    ]
}

response = requests.post(url, headers={"Content-Type": "application/json"}, json=payload)
print(response.json())

main.rs

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": "suix_getCoins",
        "params": [
            "0x94f1a597b4e8f709a396f7f6b1482bdcd65a673d111e49286c527fab7c2d0961",
            "0x2::sui::SUI",
            null,
            10
        ]
    });

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

    let result: serde_json::Value = response.json().await?;
    println!("{:#?}", result);
    
    Ok(())
}

Response Example

json{
  "jsonrpc": "2.0",
  "result": {
    "data": [
      {
        "coinType": "0x2::sui::SUI",
        "coinObjectId": "0xd62ca040aba24f862a763851c54908cd2a0ee7d709c11b93d4a2083747b76856",
        "version": "103626",
        "digest": "C9fdokK19BpDCgUgWsJv3cfd4LDyk7WGYBeGhFHbEL2Z",
        "balance": "200000000",
        "previousTransaction": "tw5DzJTfdxTn4f3rekFrhN7dQTUezBgsEhycDobTBLb"
      }
    ],
    "nextCursor": "0xd62ca040aba24f862a763851c54908cd2a0ee7d709c11b93d4a2083747b76856",
    "hasNextPage": true
  },
  "id": "getblock.io"
}

Response Parameters

ParameterTypeDescription
coinTypestringThe fully qualified coin type
coinObjectIdstringUnique identifier of the coin object
versionstringCurrent version number of the object
digeststringObject digest hash
balancestringBalance in the coin's smallest unit
previousTransactionstringLast transaction that modified this object
nextCursorstringCursor for next page
hasNextPagebooleanTrue 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 CodeDescription
-32602Invalid params - malformed address or coin type
-32603Internal error - node processing issues
-32000Server error - RPC endpoint unavailable

SDK Integration

sui.ts

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

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

const coins = await client.getCoins({
  owner: '0x94f1a597b4e8f709a396f7f6b1482bdcd65a673d111e49286c527fab7c2d0961',
  coinType: '0x2::sui::SUI',
});

console.log(coins);

main.rs

rustuse sui_sdk::SuiClientBuilder;

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