简体   繁体   English

如何使用 OpenSea JavaScript SDK 解决 404 问题?

[英]How can I solve 404 issue using the OpenSea JavaScript SDK?

I am trying to use OpenSea API with the JS SDK. I am getting two types of errors.我正在尝试将 OpenSea API 与 JS SDK 一起使用。我遇到了两种类型的错误。 One is a deprecated warning.一个是弃用警告。 Another is a 404 error.另一个是 404 错误。 This is the error I am getting no matter what request is performed,无论执行什么请求,这都是我收到的错误,

DEPRECATED: Please use providerUtils.standardizeOrThrow() instead
DEPRECATED: Please use providerUtils.standardizeOrThrow() instead
/home/sayeed/projects/SmartxNFT-main/node_modules/opensea-js/lib/api.js:509
                        throw new Error("API Error ".concat(response.status, ": ").concat(errorMessage));
                              ^

Error: API Error 404: Not found. Full message was '{"success":false}'
    at OpenSeaAPI.<anonymous> (/home/sayeed/projects/SmartxNFT-main/node_modules/opensea-js/lib/api.js:509:31)
    at step (/home/sayeed/projects/SmartxNFT-main/node_modules/opensea-js/lib/api.js:63:23)
    at Object.next (/home/sayeed/projects/SmartxNFT-main/node_modules/opensea-js/lib/api.js:44:53)
    at fulfilled (/home/sayeed/projects/SmartxNFT-main/node_modules/opensea-js/lib/api.js:35:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Here is my code following the documentation,这是我在文档之后的代码,


const Web3 = require("web3");
const { OpenSeaPort, Network } = require("opensea-js");

const HDWalletProvider = require("@truffle/hdwallet-provider");

const privateKeys = [
    "private key",
];

const provider = new HDWalletProvider(
    privateKeys,
    "https://polygon-mainnet.g.alchemy.com/v2/aclchemy - key",
    0,
    2
);

const seaport = new OpenSeaPort(provider, {
    networkName: Network.Main,
    apiKey: "api key",
});

const getAsset = async () => {
    const asset = {
        tokenAddress: "0x0ee7d6519a475a35e5c65dd0193dd1b9800e4db0", // CryptoKitties
        tokenId: "129", // Token ID
    };

    const listing = await seaport.api.getAsset(asset);

    console.log(listing);
};

getAsset();

The RPC API key is from Alchemy. RPC API 密钥来自 Alchemy。

The problem lies in the fact that opensea-js only has two.network options.问题在于opensea-js 只有两个.network 选项。 The Ethereum mai.net and the rinkeby tes.net.以太坊 mai.net 和 rinkeby tes.net。

In the following line you can see that you are setting your seaport to be using the Ethereum Mai.net.在下一行中,您可以看到您正在将海港设置为使用以太坊 Mai.net。

networkName: Network.Main,网络名称:Network.Main,

The returning value of Network.Main it's a string which contains the word main and while this might seem to imply that you could simply change Network.Main to "polygon" the sdk will just throw error. Network.Main的返回值是一个包含单词main的字符串,虽然这似乎暗示您可以简单地将Network.Main更改为"polygon" ,但 sdk 只会抛出错误。

Right now neither the OpenSea API, nor the opensea-sdk support Polygon, but they've announced that for V2 OpenSea API will support Polygon.现在 OpenSea API 和 opensea-sdk 都不支持 Polygon,但是他们已经宣布对于 V2 OpenSea API 将支持 Polygon。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM