Query several ERC-1155 balances in one contract call

An ERC-1155 contract can hold many asset IDs for many accounts. Its batch balance method pairs the two input arrays by position.

Build the pairs before encoding

To check IDs 7 and 8 for Alice and ID 7 for Bob, repeat Alice in the first array. ABI-encode balanceOfBatch(address[],uint256[]) for the collection and call it at the snapshot block.

accounts = [Alice, Alice, Bob]
ids      = [7,     8,     7]

For a decoded result [3,0,9], Alice holds three units of ID 7 and zero of ID 8. Bob holds nine units of ID 7. Keep the input tuples alongside the response so that sorting IDs during display does not reassign balances.

Keep the contract boundary

Both arrays must have the same length, and each account must be a valid nonzero owner. Group calls by collection and chain. Asset ID 7 from another contract belongs to a different balance space. eips.ethereum.org ERC-1155