OpenSea SDK - Unable to create sell listing for token from a factory-deployed contract, but no error messages?

Viewed 728

I'm learning how to use the OpenSea SDK in Node.js (found here) by referring to its example OpenSea Creatures. The SDK links to a two-year old branch but I'm using the master branch.

I'm trying to create a factory that can deploy contracts from which tokens are minted. For testing purposes, I'm having my factory deploy the Creatures contract, and this is my Solidity code:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/access/Ownable.sol";
import "./ERC721Tradable.sol";

contract NFTContractFactory is Ownable
{
    event ContractCreated(address addr);

    function createContract(string memory name, string memory symbol)
        public onlyOwner
    {
        Creature nc = new Creature(name, symbol, owner());
        nc.transferOwnership(msg.sender);
        emit ContractCreated(address(nc));
    }
}

contract Creature is ERC721Tradable {
    constructor(string memory _name, string memory _symbol, address _proxyRegistryAddress)
        ERC721Tradable(_name, _symbol, _proxyRegistryAddress)
    {}

    function baseTokenURI() override public pure returns (string memory) {
        return "https://creatures-api.opensea.io/api/creature/";
    }

    function contractURI() public pure returns (string memory) {
        return "https://creatures-api.opensea.io/contract/opensea-creatures";
    }
}

ERC721Tradable.sol can be found here. The only change I've made to the Creature contract was to have its name and symbol be passed from the factory.

I have deployed samples of these contracts at the following addresses:

  • NFTContractFactory: 0xbc2e680be967834a5f6fd72ac9e2b0251f28b2a8
  • Creature: 0x5126c9f90a18c197dc8964ea477d63bcfbef97ab, 0xf9473fa26c4631dcd2ee1c7ad50e0c3545ff35a7, 0x5c7f60d78774f81989b262da785daf7b6a2aed2b

This is my test script:

const Web3 = require('web3')
const OpenSea = require('opensea-js')
const OpenSeaPort = OpenSea.OpenSeaPort
const Network = OpenSea.Network

const MnemonicWalletSubprovider = require("@0x/subproviders").MnemonicWalletSubprovider;
const MNEMONIC = 'my metamask wallet mnemonic'
const BASE_DERIVATION_PATH = `44'/60'/0'/0`;
const mnemonicWalletSubprovider = new MnemonicWalletSubprovider({
  mnemonic: MNEMONIC,
  baseDerivationPath: BASE_DERIVATION_PATH,
});

const RPCSubprovider = require("web3-provider-engine/subproviders/rpc");
const alchemyRpcSubprovider = new RPCSubprovider("my alchemy rinkeby endpoint");

const Web3ProviderEngine = require("web3-provider-engine");
const providerEngine = new Web3ProviderEngine();
providerEngine.addProvider(mnemonicWalletSubprovider);
providerEngine.addProvider(alchemyRpcSubprovider);
providerEngine.start();

const seaport = new OpenSeaPort(
  providerEngine,
  {
    networkName: Network.Rinkeby,
    apiKey: ""
  },
  (arg) => console.log(arg)
);

async function main() {
  // Expire this auction one day from now. Note that we convert from the JavaScript timestamp (milliseconds):
  const expirationTime = Math.round(Date.now() / 1000 + 60 * 60 * 24)

  const assetPromise = seaport.api.getAsset({
    tokenAddress: '0xf9473fa26c4631dcd2ee1c7ad50e0c3545ff35a7',
    tokenId: '1',
  })
  assetPromise.then(asset => {
    console.log(asset);
    const sellOrderPromise = seaport.createSellOrder({
      asset,
      accountAddress: 'my address',
      startAmount: 3,
      // If `endAmount` is specified, the order will decline in value to that amount until `expirationTime`. Otherwise, it's a fixed-price order:
      endAmount: 0.1,
      expirationTime
    });
    sellOrderPromise.then(order => console.log(order)).catch(error => console.log(error));
  });
}

main()

Unfortunately, my test output consists of only the token information from that line console.log(asset);; I don't even see the final order or any errors, and I don't see my listing being created either. I'm not sure how to troubleshoot this so I'd be so thankful if someone could point me in the right direction from here.

Edit1: Added .catch(error => console.log(error)); to catch any errors, but still nothing!

Edit2: Seems like I'm not the only one with the silent failure? Issue here

0 Answers
Related