user2068: I am working on an app, I am using Nami wallet and cardano-serialization-lib.
When I query UTxO and decode it using cardano-serialization-lib, I get an object with only attribute is something called "ptr", ptr is a number I was expecting an actual UTxO... I want to know how can I get the UTXO because I want it for using it inside a policy script.
Edit:
Extended explanation: I run the following comands in my browser:
window.cardano.enable();
window.cardano.getUtxos();

I get this :
Promise {<pending>}[[Prototype]]: Promise[[PromiseState]]: "fulfilled"[[PromiseResult]]: Array(1)0: "82825820eef507b798abbb8a1360efbd113f51eda22e2fbaae3cc32c78724c8644c164a40082583900756e62ff9667b187209b6fe1b577061491cf6f93a81e1f91741e2e3accb864ae67087f69bbd9ab74f71781d13ae40aab86e1de30ca7e21171a1dcd6500"length: 1[[Prototype]]: Array(0)

when i decode it using the library in NodeJS with the following script:
const S = require("./node_modules/@emurgo/cardano-serialization-lib-nodejs/cardano_serialization_lib.js");
const _Buffer = require("buffer/").Buffer;
const rawUtxo =
  "82825820eef507b798abbb8a1360efbd113f51eda22e2fbaae3cc32c78724c8644c164a40082583900756e62ff9667b187209b6fe1b577061491cf6f93a81e1f91741e2e3accb864ae67087f69bbd9ab74f71781d13ae40aab86e1de30ca7e21171a1dcd6500";

const utxos = S.TransactionUnspentOutput.from_bytes(
  _Buffer.from(rawUtxo, "hex")
);

console.log(utxos); 

I get this:
TransactionUnspentOutput { ptr: 1179656 },

user4593: The serialization lib is written in Rust and compiled to web assembly. Rust manually manages its memory, and I'm assuming that you need to do the same here. If you look at the typescript types you can see that every object has a free() method.
The ptr is a pointer to memory. If you need to access information of the UTXO you need to use the provided functions. So for example, this will construct the TransactionOutput from the CBOR hex string
const fromHexString = hexString =>
  new Uint8Array(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));

const utxos = await cardano
        .getUtxos()
        .then(cborUTXOS => 
                cborUTXOS.map(cborUTXO => 
                        CardanoWasm.TransactionUnspentOutput.from_bytes(fromHexString(cborUTXO))
                    )
             )

And you can see how many lovelaces an output has like this:
utxos[0].output().amount().coin().to_str()


2068: <p>I am working on an app, I am using Nami wallet and <a href="https://github.com/Emurgo/cardano-serialization-lib" rel="nofollow noreferrer">cardano-serialization-lib</a>.</p>
<p>When I query UTxO and decode it using <code>cardano-serialization-lib</code>, I get an object with only attribute is something called &quot;ptr&quot;, ptr is a number I was expecting an actual UTxO... I want to know how can I get the UTXO because I want it for using it inside a policy script.</p>
<p><strong>Edit</strong>:</p>
<p>Extended explanation: I run the following comands in my browser:</p>
<pre><code>window.cardano.enable();
window.cardano.getUtxos();
</code></pre>
<p>I get this :</p>
<pre><code>Promise {&lt;pending&gt;}[[Prototype]]: Promise[[PromiseState]]: &quot;fulfilled&quot;[[PromiseResult]]: Array(1)0: &quot;82825820eef507b798abbb8a1360efbd113f51eda22e2fbaae3cc32c78724c8644c164a40082583900756e62ff9667b187209b6fe1b577061491cf6f93a81e1f91741e2e3accb864ae67087f69bbd9ab74f71781d13ae40aab86e1de30ca7e21171a1dcd6500&quot;length: 1[[Prototype]]: Array(0)
</code></pre>
<p>when i decode it using the library in NodeJS with the following script:</p>
<pre><code>const S = require(&quot;./node_modules/@emurgo/cardano-serialization-lib-nodejs/cardano_serialization_lib.js&quot;);
const _Buffer = require(&quot;buffer/&quot;).Buffer;
const rawUtxo =
  &quot;82825820eef507b798abbb8a1360efbd113f51eda22e2fbaae3cc32c78724c8644c164a40082583900756e62ff9667b187209b6fe1b577061491cf6f93a81e1f91741e2e3accb864ae67087f69bbd9ab74f71781d13ae40aab86e1de30ca7e21171a1dcd6500&quot;;

const utxos = S.TransactionUnspentOutput.from_bytes(
  _Buffer.from(rawUtxo, &quot;hex&quot;)
);

console.log(utxos); 
</code></pre>
<p>I get this:</p>
<p>TransactionUnspentOutput { ptr: 1179656 },</p>
 4593: <p>The serialization lib is written in Rust and compiled to web assembly. Rust manually manages its memory, and I'm assuming that you need to do the same here. If you look at the typescript types you can see that every object has a <code>free()</code> method.</p>
<p>The ptr is a pointer to memory. If you need to access information of the UTXO you need to use the provided functions. So for example, this will construct the TransactionOutput from the CBOR hex string</p>
<pre><code>const fromHexString = hexString =&gt;
  new Uint8Array(hexString.match(/.{1,2}/g).map(byte =&gt; parseInt(byte, 16)));

const utxos = await cardano
        .getUtxos()
        .then(cborUTXOS =&gt; 
                cborUTXOS.map(cborUTXO =&gt; 
                        CardanoWasm.TransactionUnspentOutput.from_bytes(fromHexString(cborUTXO))
                    )
             )
</code></pre>
<p>And you can see how many lovelaces an output has like this:</p>
<pre><code>utxos[0].output().amount().coin().to_str()
</code></pre>
