通过 JS API 在 OpenSea 上列出 NFT:无法提取 transfer calldata 错误 400

Posted

技术标签:

【中文标题】通过 JS API 在 OpenSea 上列出 NFT:无法提取 transfer calldata 错误 400【英文标题】:Listing NFT on OpenSea via JS API: Failed to extract transfer calldata Error 400 【发布时间】:2021-07-19 17:34:31 【问题描述】:

我正在尝试使用OpenSea javascript API 来自动列出要出售的 NFT。我似乎无法弄清楚为什么我不断收到错误Error: API Error 400: ['Failed to extract transfer calldata']。也许我没有正确输入一些数据?我的代码改编自this example。

来源

const opensea = require("opensea-js");
const OpenSeaPort = opensea.OpenSeaPort;
const Network = opensea.Network;
const MnemonicWalletSubprovider = require("@0x/subproviders")
  .MnemonicWalletSubprovider;
const RPCSubprovider = require("web3-provider-engine/subproviders/rpc");
const Web3ProviderEngine = require("web3-provider-engine");

const MNEMONIC = "SECRET ...";
const NODE_API_KEY = "FROM INFURA";
const isInfura = true;
//const FACTORY_CONTRACT_ADDRESS = process.env.FACTORY_CONTRACT_ADDRESS;
const NFT_CONTRACT_ADDRESS = "0x495f947276749Ce646f68AC8c248420045cb7b5e";
const OWNER_ADDRESS = "0x3eb8eea9565418281f4cae934dd69e7ff2bb5949";
const NETWORK = "mainnet";
const API_KEY = process.env.API_KEY || ""; // API key is optional but useful if you're doing a high volume of requests.

const BASE_DERIVATION_PATH = `44'/60'/0'/0`;

const mnemonicWalletSubprovider = new MnemonicWalletSubprovider(
  mnemonic: MNEMONIC,
  baseDerivationPath: BASE_DERIVATION_PATH,
);
const network =
  NETWORK === "mainnet" || NETWORK === "live" ? "mainnet" : "rinkeby";
const infuraRpcSubprovider = new RPCSubprovider(
  rpcUrl: isInfura
    ? "https://" + network + ".infura.io/v3/" + NODE_API_KEY
    : "https://eth-" + network + ".alchemyapi.io/v2/" + NODE_API_KEY,
);

const providerEngine = new Web3ProviderEngine();
providerEngine.addProvider(mnemonicWalletSubprovider);
providerEngine.addProvider(infuraRpcSubprovider);
providerEngine.start();

const seaport = new OpenSeaPort(
  providerEngine,
  
    networkName:
      NETWORK === "mainnet" || NETWORK === "live"
        ? Network.Main
        : Network.Rinkeby,
    apiKey: API_KEY,
  ,
  (arg) => console.log(arg)
);

exports.helloWorld = async (req, res) => 
  // Example: simple fixed-price sale of an item owned by a user.
  console.log("Auctioning an item for a fixed price...");

  try 
    const fixedPriceSellOrder = await seaport.createSellOrder(
      asset: 
        tokenId: "28370143653034713195993216915191765879963367987017833025925208213530804748289",
        tokenAddress: NFT_CONTRACT_ADDRESS,
      ,
      startAmount: 0.1,
      expirationTime: 0,
      accountAddress: OWNER_ADDRESS,
    );
    console.log(
      `Successfully created a fixed-price sell order! $fixedPriceSellOrder.asset.openseaLink\n`
    );
  
  catch (error) 
    console.log("ERROR",error);
  

;

完整日志

我在哪里获得数据

ASSET URL

【问题讨论】:

你能解决这个问题吗?我遇到了同样的问题。 【参考方案1】:

你的代币标准是什么?

如果不是 ERC721,则需要在资产对象中将其指定为 schemaName,如下所示:

const fixedPriceSellOrder = await seaport.createSellOrder(
      asset: 
        tokenId: "28370143653034713195993216915191765879963367987017833025925208213530804748289",
        tokenAddress: NFT_CONTRACT_ADDRESS,
        schemaName: "ERC1155"
      ,
      startAmount: 0.1,
      expirationTime: 0,
      accountAddress: OWNER_ADDRESS,
    );

您可以在 Opensea 资产页面的 Details 选项卡中找到 Token Standard:

删除破折号,你很好。 ERC1155 对我来说很好。

【讨论】:

以上是关于通过 JS API 在 OpenSea 上列出 NFT:无法提取 transfer calldata 错误 400的主要内容,如果未能解决你的问题,请参考以下文章

请求opensea api失败

OpenSea API文档中文版

查找 Opensea NFT 的楼层

OpenSea PHP开发包

弄清楚如何通过延迟发布、元数据未在 opensea 上验证来铸造 NFT

如何创建像 OpenSea 这样的签名交易