XRPLF / xrpl.js

A JavaScript/TypeScript API for interacting with the XRP Ledger in Node.js and the browser
https://xrpl.org/
1.21k stars 512 forks source link

Resolve TokenId #1897

Closed tequdev closed 2 years ago

tequdev commented 2 years ago

Can we resolve TokenID of NFToken object?

like: anyFunc(000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65)

return

{
    Flags: 12,
    TransferFee: 0.0314,
    Issuer: rNCFjv8Ek5oDrNiMJ3pw6eLLFtMjZLJnf2,
    Taxon: 146999694,
    Sequence: 3429,
}
JST5000 commented 2 years ago

I don't believe there's any rippled request which can do that unfortunately.

Closest thing I could find in the XLS 20d spec is this description of how to search for NFTokens:

To search for a specific NFToken, the first step is to locate the NFTokenPage, if any, that should contain that NFToken. For that do the following:

Compute the NFTokenPageID using the account of the owner and the TokenID of the token, as described above. Then search for the ledger entry whose identifier is less than or equal to that value. If that entry does not exist or is not an NFTokenPage, the NFToken is not held by the given account.

https://github.com/XRPLF/XRPL-Standards/discussions/46

(One way to build your own TokenId lookup is to have a database which watches the ledger and updates whenever you see a TokenMint, which you can then search for TokenIds in whichever manner you want)

yyolk commented 2 years ago

I would like to add this to xrpl-py too (if it doesn't exist yet 😀)

if I'm not mistaken OP wants to translate the encoded id into the unpacked map image

JST5000 commented 2 years ago

Oh shoot, sorry for misinterpreting!

That makes sense :)

tequdev commented 2 years ago

if I'm not mistaken OP wants to translate the encoded id into the unpacked map

Yes, that's correct.

tequdev commented 2 years ago

I don't know how to decode the encoded address 95F14B0044F78A264E41713C64B5F89242540EE2 to rNCFjv8Ek5oDrNiMJ3pw6eLLFtMjZLJnf2.

ihomp commented 2 years ago

+1, would be nice to have it in the lib.

ildaruz commented 2 years ago

I don't know how to decode the encoded address 95F14B0044F78A264E41713C64B5F89242540EE2 to rNCFjv8Ek5oDrNiMJ3pw6eLLFtMjZLJnf2.

You can use "ripple-address-codec" to get rAddress AddressCodec.encodeAccountID(Buffer.from("95F14B0044F78A264E41713C64B5F89242540EE2", "hex")); Our temp solution https://github.com/Bithomp/xrpl-api/blob/master/src/client/account_nfts.ts#L227

ckniffen commented 2 years ago

Closed by #1961