获取给定 NFT 合约的当前代币所有者

发布于 2025-01-16 06:17:53 字数 972 浏览 6 评论 0原文

我正在尝试交叉引用我的本地数据库并确认 NFT 代币的所有权。我有合约地址和用户钱包地址,我试图获取该用户为该给定合约拥有的所有当前代币的返回数组。如果我访问 etherscan 合约页面,我可以手动输入给定钱包的地址并获取我需要的内容:

r

是否有一个简单的 API 可以用来获取合约下所有代币的当前所有者?我尝试了下面 Etherscan 的 api,但它不会返回当前所有权,而是返回交易列表。

<一href="https://api-rinkeby.etherscan.io/api?module=account&action=tokennfttx&contractaddress=0x1481e948f2cc7886D454532714D011A7D8e9ec2e&ad衣服=0xe93FBC84f5743Ec68a03260f4A9A23c708593d02&page=1&offset=10000&startblock=0&endblock=27025780&sort=asc&apikey=$myapikey" rel="nofollow noreferrer">https://api-rinkeby.etherscan.io/api?module=account&action=tokennfttx&contractaddress=0x1481e948f2cc7886D454532714D011A7D8e9ec2e&a地址=0xe93FBC84f5743Ec68a03260f4A9A23c708593d02&page=1&offset=10000&startblock=0&endblock=27025780&sort=asc&apikey=$myapikey

I am attempting to cross-reference my local database and confirm ownership of an NFT token. I have the contract address and the users wallet address and Im trying to get a returned array of all current tokens owned by that user for that given contract. If I visit the etherscan contract page I can manually enter the address of the given wallet and get just what I need:

r

Is there a simple API I can use to get just the current owner of all tokens under a contract? I tried the api from Etherscan below however that doesn't return current ownership, but a list of the transactions.

https://api-rinkeby.etherscan.io/api?module=account&action=tokennfttx&contractaddress=0x1481e948f2cc7886D454532714D011A7D8e9ec2e&address=0xe93FBC84f5743Ec68a03260f4A9A23c708593d02&page=1&offset=10000&startblock=0&endblock=27025780&sort=asc&apikey=$myapikey

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

榕城若虚 2025-01-23 06:17:53

尝试使用 OpenSea 的检索资产端点。

const { data } = await axios.get(
    `https://api.opensea.io/api/v1/collections?asset_owner=${userAddress}`,
    {
        headers: {
            Accept: "application/json",
            "X-API-KEY": process.env.OPENSEA_API,
        },
    }
);

这将返回给定用户资产的数组。

另一种选择是 使用 Etherscan API 按地址获取“ERC721 - 代币转移事件”列表

const tokenTransfersByAddress = async (contractaddress, address) => {
        try {
            const options = {
                method: "GET",
                url: "https://api.etherscan.io/api",
                params: {
                    module: "account",
                    action: "tokennfttx",
                    contractaddress,
                    address,
                    page: "1",
                    offset: "10",
                    sort: "asc",
                    apikey: process.env.ETHERSCAN,
                },
            };

            const { data } = await axios.request(options);
            return data.result;
        } catch (error) {
            console.log(error);
            return [];
        }
    };

这将返回给定用户已进行的交易的数组。

希望这有帮助!

Try using to OpenSea's Retrieving assets endpoint.

const { data } = await axios.get(
    `https://api.opensea.io/api/v1/collections?asset_owner=${userAddress}`,
    {
        headers: {
            Accept: "application/json",
            "X-API-KEY": process.env.OPENSEA_API,
        },
    }
);

This returns an array of a given user's assets.

Another option is to Get a list of 'ERC721 - Token Transfer Events' by Address using Etherscan API

const tokenTransfersByAddress = async (contractaddress, address) => {
        try {
            const options = {
                method: "GET",
                url: "https://api.etherscan.io/api",
                params: {
                    module: "account",
                    action: "tokennfttx",
                    contractaddress,
                    address,
                    page: "1",
                    offset: "10",
                    sort: "asc",
                    apikey: process.env.ETHERSCAN,
                },
            };

            const { data } = await axios.request(options);
            return data.result;
        } catch (error) {
            console.log(error);
            return [];
        }
    };

This returns an array of transactions a given user has made.

Hope this helps!

无戏配角 2025-01-23 06:17:53

您可以使用一个简单的工具 holders.at 获取并导出任何区块的所有 NFT 代币持有者。它支持以太坊和Polygon集合。

You can use a simple tool holders.at to take and export all NFT token holders at any block. It supports Ethereum and Polygon collections.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文