XRPLF / xrpl.js

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

How to get owner of NFToken? #2003

Closed Satosh-J closed 2 years ago

Satosh-J commented 2 years ago

Hello. I'm making buy offer in xrp20d. This requires txBlob like this.

const transactionBlob = {
        "TransactionType": "NFTokenCreateOffer",
        "Account": wallet.classicAddress,
        "Owner": owner,
        "NFTokenID": nftokenId,
        "Amount": 2000
        "Flags": 2
  }

For this, I should know the current owner of NFToken. How can I get owner account address from NFTokenID? Or is there any other way to make buy offer without knowing owner?

JST5000 commented 2 years ago

Hey Satosh-J, currently there's no way within XLS-20 to determine the owner from the NFTokenID directly.

One way that's being resolved is with Clio (a companion to validators that can offer additional requests) - See this comment in response to a similar question on the spec itself: https://github.com/XRPLF/XRPL-Standards/discussions/46#discussioncomment-2548482

Alternatively, you can use the NFTokenID to get the issuer of the token, then trace back the transactions which involve that token until you find the eventual owner.

The steps for that would be:

  1. Decode an NFTokenID to get the issuer (You can use parse_nftoken_id in xrpl-py or parseNFTokenID in xrpl.js)
  2. Send an account_tx request for that issuer until you find the transaction that trades the NFToken (https://xrpl.org/account_tx.html)
  3. Repeat step 2 on each account until you find the eventual owner. (No transactions trading the NFToken between the ledger that account bought the token on, and the current ledger)

The Clio option will eventually be a very easy-to-use answer to this question, but unfortunately for now it's not quite ready.

Satosh-J commented 2 years ago

Thanks you very much.