# Multi-Chain Accounts Query and manage accounts across Kadena's 20 braided chains. Track balances, discover accounts by public key, and aggregate multi-chain holdings. ## fungibleAccount: Cross-Chain Balance Aggregation Retrieve account information across all chains with total balance calculation. ```graphql query CrossChainAccount($accountName: String!, $fungibleName: String) { fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) { accountName fungibleName totalBalance chainAccounts { chainId balance guard { ... on KeysetGuard { keys predicate } } } } } ``` **Variables** ```json { "accountName": "k:abcdef123456789", "fungibleName": "coin" } ``` **Response** ```json { "data": { "fungibleAccount": { "accountName": "k:abcdef123456789", "fungibleName": "coin", "totalBalance": 15750.50, "chainAccounts": [ { "chainId": "0", "balance": 5000.25, "guard": { "keys": [ "abcdef123456789" ], "predicate": "keys-all" } }, { "chainId": "1", "balance": 8500.00, "guard": { "keys": [ "abcdef123456789" ], "predicate": "keys-all" } }, { "chainId": "2", "balance": 2250.25, "guard": { "keys": [ "abcdef123456789" ], "predicate": "keys-all" } } ] } } } ``` **Use Cases** - Multi-chain wallet interfaces - Total portfolio balance display - Cross-chain balance aggregation - Chain-specific balance breakdown **Notes** totalBalance sums all chainAccounts balances. Missing chainIds indicate zero balance. Each chainAccount includes guard information. Use fungibleName to query different tokens (defaults to "coin" for KDA). ## fungibleAccountsByPublicKey: Account Discovery Find all accounts controlled by a public key across the network. ```graphql query AccountsByPublicKey($publicKey: String!, $fungibleName: String) { fungibleAccountsByPublicKey( publicKey: $publicKey fungibleName: $fungibleName ) { accountName fungibleName totalBalance chainAccounts { chainId balance guard { ... on KeysetGuard { keys predicate } } } } } ``` **Variables** ```json { "publicKey": "abcdef123456789", "fungibleName": "coin" } ``` **Response** ```json { "data": { "fungibleAccountsByPublicKey": [ { "accountName": "k:abcdef123456789", "fungibleName": "coin", "totalBalance": 15750.50, "chainAccounts": [ { "chainId": "0", "balance": 5000.25, "guard": { "keys": [ "abcdef123456789" ], "predicate": "keys-all" } }, { "chainId": "1", "balance": 8500.00, "guard": { "keys": [ "abcdef123456789" ], "predicate": "keys-all" } } ] }, { "accountName": "my-custom-account", "fungibleName": "coin", "totalBalance": 3500.00, "chainAccounts": [ { "chainId": "0", "balance": 3500.00, "guard": { "keys": [ "abcdef123456789", "xyz987654321" ], "predicate": "keys-2" } } ] } ] } } ``` **Use Cases** - Account discovery by key - Multi-account portfolio tracking - Key-based account enumeration - Cross-account balance aggregation **Notes** Returns all accounts where publicKey is in the guard's keys array. Single key can control multiple accounts. Accounts may have different guard predicates (keys-all, keys-2, etc.). Useful for discovering contract-based accounts. ## fungibleChainAccounts: Specific Chain Query Retrieve account details across specified chains only. ```graphql query SpecificChainAccounts( $accountName: String! $chainIds: [String!] $fungibleName: String ) { fungibleChainAccounts( accountName: $accountName chainIds: $chainIds fungibleName: $fungibleName ) { accountName chainId balance fungibleName guard { ... on KeysetGuard { keys predicate } } } } ``` **Variables** ```json { "accountName": "k:abcdef123456789", "chainIds": ["0", "1", "8"], "fungibleName": "coin" } ``` **Response** ```json { "data": { "fungibleChainAccounts": [ { "accountName": "k:abcdef123456789", "chainId": "0", "balance": 5000.25, "fungibleName": "coin", "guard": { "keys": [ "abcdef123456789" ], "predicate": "keys-all" } }, { "accountName": "k:abcdef123456789", "chainId": "1", "balance": 8500.00, "fungibleName": "coin", "guard": { "keys": [ "abcdef123456789" ], "predicate": "keys-all" } }, { "accountName": "k:abcdef123456789", "chainId": "8", "balance": 1250.50, "fungibleName": "coin", "guard": { "keys": [ "abcdef123456789" ], "predicate": "keys-all" } } ] } } ``` **Use Cases** - Targeted chain balance queries - Chain-specific transaction history - Selective chain monitoring - Reduced payload for specific chains **Notes** Only returns data for specified chainIds. More efficient than querying all chains when only specific chains are relevant. Each chain account is independent with its own balance and guard. ## fungibleChainAccountsByPublicKey: Chain-Specific Discovery Find all accounts controlled by a public key on a specific chain. ```graphql query ChainAccountsByKey( $chainId: String! $publicKey: String! $fungibleName: String ) { fungibleChainAccountsByPublicKey( chainId: $chainId publicKey: $publicKey fungibleName: $fungibleName ) { accountName chainId balance fungibleName guard { ... on KeysetGuard { keys predicate } } } } ``` **Variables** ```json { "chainId": "0", "publicKey": "abcdef123456789", "fungibleName": "coin" } ``` **Response** ```json { "data": { "fungibleChainAccountsByPublicKey": [ { "accountName": "k:abcdef123456789", "chainId": "0", "balance": 5000.25, "fungibleName": "coin", "guard": { "keys": [ "abcdef123456789" ], "predicate": "keys-all" } }, { "accountName": "my-contract-account", "chainId": "0", "balance": 15000.00, "fungibleName": "coin", "guard": { "keys": [ "abcdef123456789", "contract-key-123" ], "predicate": "keys-2" } } ] } } ``` **Use Cases** - Chain-specific account discovery - Multi-sig account identification - Contract account enumeration - Single-chain portfolio tracking **Notes** Returns accounts on specific chain only. Useful for finding contract accounts or multi-sig arrangements. Multiple accounts can share the same public key with different predicates. ## Cross-Chain NFT Holdings Track non-fungible token holdings across multiple chains. ```graphql query CrossChainNFTs($accountName: String!) { nonFungibleAccount(accountName: $accountName) { accountName chainAccounts { chainId nonFungibleTokenBalances { tokenId balance chainId info { uri supply precision } } } } } ``` **Variables** ```json { "accountName": "k:abcdef123456789" } ``` **Response** ```json { "data": { "nonFungibleAccount": { "accountName": "k:abcdef123456789", "chainAccounts": [ { "chainId": "8", "nonFungibleTokenBalances": [ { "tokenId": "nft-collection-1:123", "balance": 1, "chainId": "8", "info": { "uri": "https://nft-metadata.example.com/123", "supply": 1, "precision": 0 } }, { "tokenId": "nft-collection-2:456", "balance": 1, "chainId": "8", "info": { "uri": "https://nft-metadata.example.com/456", "supply": 1, "precision": 0 } } ] }, { "chainId": "1", "nonFungibleTokenBalances": [ { "tokenId": "nft-collection-3:789", "balance": 1, "chainId": "1", "info": { "uri": "https://nft-metadata.example.com/789", "supply": 1, "precision": 0 } } ] } ] } } } ``` **Use Cases** - Multi-chain NFT portfolio - Cross-chain NFT discovery - Complete NFT inventory - Chain-specific NFT holdings **Notes** NFTs often concentrated on specific chains (commonly chain 8). Each chainAccount includes NFT balances for that chain. Balance typically 1 for owned NFTs, 0 for transferred. Use uri to fetch metadata.