user2068: Hello I am building a daap and i wanted to save blockFrost requests so I wonder if it is posible to fetch all assets using the nami wallet? I was trying with the window.cardano.get balance() , after using cardano serialization lib  with Value.from_bytes() I get the ada total using Value.from_bytes().coin().to_str()  but for all the other methods defined on Value.from_bytes() i can not find any that allows me to get .to_str() ... so even if i think that the total assets is in the original Value, I can not read it. Any help?

user2077: You could try this out. Basically assets are under value.multiassets() and is a double map from policy ID => assetName => quantity. You can iterate over this map with 2 for loops:
const value = CSL.Value.from_bytes(...) // your value
const lovelace = value.coin().to_str();
if (value.multiasset()) {
const multiAssets = value.multiasset().keys();
for (let j = 0; j < multiAssets.len(); j++) {
  const policy = multiAssets.get(j);
  const policyAssets = value.multiasset().get(policy);
  const assetNames = policyAssets.keys();
  for (let k = 0; k < assetNames.len(); k++) {
    const assetPolicy = Buffer.from(policy.to_bytes()).toString("hex"); // hex encoded policy
    const assetName = Buffer.from(
      assetNames.get(k).name(),
      "hex"
    ).toString(); // utf8 encoded asset name
    const quantity = policyAssets.get(assetNames.get(k)).to_str(); // asset's quantity

    // your code here

  }
}


2068: <p>Hello I am building a daap and i wanted to save blockFrost requests so I wonder if it is posible to fetch all assets using the nami wallet? I was trying with the window.cardano.get balance() , after using cardano serialization lib  with Value.from_bytes() I get the ada total using Value.from_bytes().coin().to_str()  but for all the other methods defined on Value.from_bytes() i can not find any that allows me to get .to_str() ... so even if i think that the total assets is in the original Value, I can not read it. Any help?</p>
 2077: <p>You could try this out. Basically assets are under value.multiassets() and is a double map from policy ID =&gt; assetName =&gt; quantity. You can iterate over this map with 2 for loops:</p>
<pre><code>const value = CSL.Value.from_bytes(...) // your value
const lovelace = value.coin().to_str();
if (value.multiasset()) {
const multiAssets = value.multiasset().keys();
for (let j = 0; j &lt; multiAssets.len(); j++) {
  const policy = multiAssets.get(j);
  const policyAssets = value.multiasset().get(policy);
  const assetNames = policyAssets.keys();
  for (let k = 0; k &lt; assetNames.len(); k++) {
    const assetPolicy = Buffer.from(policy.to_bytes()).toString(&quot;hex&quot;); // hex encoded policy
    const assetName = Buffer.from(
      assetNames.get(k).name(),
      &quot;hex&quot;
    ).toString(); // utf8 encoded asset name
    const quantity = policyAssets.get(assetNames.get(k)).to_str(); // asset's quantity

    // your code here

  }
}
</code></pre>
