suix_getAllCoins{deprecated} - Sui

This method returns all Coin objects owned by an address on the SUI network with pagination support. Unlike suix_getAllBalances which returns aggregated totals, this method returns individual coin objects with their unique IDs, versions, and balances. This is essential for transaction building, coin selection algorithms, and detailed asset management.

This method is deprecated

Parameters

ParameterTypeRequiredDescription
ownerSuiAddressYesThe owner's SUI address (0x prefixed hex string)
cursorstringNoOptional paging cursor for pagination
limituintNoMaximum number of items per page (default varies by node)

Returns

FieldTypeDescription
dataarrayArray of Coin objects with detailed information
nextCursorstringCursor for fetching the next page of results
hasNextPagebooleanIndicates if more results are available

Request Example

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_getAllCoins",
  "params": [
    "0x94f1a597b4e8f709a396f7f6b1482bdcd65a673d111e49286c527fab7c2d0961",
    null,
    10
  ]
}'

example.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_getAllCoins',
  params: [
    '0x94f1a597b4e8f709a396f7f6b1482bdcd65a673d111e49286c527fab7c2d0961',
    null,
    10
  ]
};

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

example.py

pythonimport requests
import json

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

payload = {
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "method": "suix_getAllCoins",
    "params": [
        "0x94f1a597b4e8f709a396f7f6b1482bdcd65a673d111e49286c527fab7c2d0961",
        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_getAllCoins",
        "params": [
            "0x94f1a597b4e8f709a396f7f6b1482bdcd65a673d111e49286c527fab7c2d0961",
            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": "0x861c5e055605b2bb1199faf653a8771e448930bc95a0369fad43a9870a2e5878",
        "version": "103626",
        "digest": "Ao1QyN9UTmYzb2ead3D5xhSBk7TvACRvmnJW8gRbwP99",
        "balance": "200000000",
        "previousTransaction": "7dp5WtTmtGp83EXYYFMzjBJRFeSgR67AzqMETLrfgeFx"
      }
    ],
    "nextCursor": "0x861c5e055605b2bb1199faf653a8771e448930bc95a0369fad43a9870a2e5878",
    "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 for verification
balancestringBalance held in this specific coin object
previousTransactionstringDigest of the transaction that last modified this object
nextCursorstringCursor for pagination to fetch next page
hasNextPagebooleanTrue if more results exist beyond this page

Use Cases

  • Select specific coin objects for transaction inputs
  • Implement coin selection algorithms for optimal gas usage
  • Display detailed coin inventory in wallets
  • Merge multiple small coin objects into larger ones
  • Track individual coin object history

Error Handling

Error CodeDescription
-32602Invalid params - malformed address or cursor
-32603Internal error - node processing issues
-32000Server error - RPC endpoint unavailable

SDK Integration

example.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.getAllCoins({
  owner: '0x94f1a597b4e8f709a396f7f6b1482bdcd65a673d111e49286c527fab7c2d0961',
});

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_all_coins(address, None, None).await?;
    
    println!("{:?}", coins);
    Ok(())
}