Thanks! This looks like a type mismatch, as contract_id() returns a ContractId, so the key you provided is of type (ContractId, ContractId) instead of (Address, ContractId). You might want to consider using Identity instead, which can be either an Address or ContractId: Blockchain Types - The Sway Programming Language
let identity = Identity::ContractId(contract_id);
let total_balance = methods
.total_balance_of(identity)
.set_contracts(&cotarcts)
.simulate()
.await
.unwrap();
println!("total_balance: {}", total_balance.value);
And the address cannot be used as an argument because of a compilation error
error
--> /Users/alexey/projects/fuel/money-box/src/main.sw:93:35
|
91 |
92 | // };
93 | balance_of(contract_id(), asset_id)
| ^^^^^^^^ Mismatched types.
expected: ContractId
found: Address.
help: The argument that has been provided to this function's type does not match the declared type of the parameter in the function declaration.
94 | }
95 | }
|
____