0

Working with OpenSea.js and have the following code but the output is absolutely nothing. Can someone help?

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

// This example provider won't let you make transactions, only read-only calls:
const provider = new Web3.providers.HttpProvider("https://mainnet.infura.io");

const seaport = new OpenSea.OpenSeaPort(provider, {
  networkName: OpenSea.Network.Main,
});

const asset = {
  tokenAddress: "0xa406489360a47af2c74fc1004316a64e469646a5",
  tokenId: "2577",
};

async function getBalance() {
  let balance = await seaport.getAssetBalance({
    accountAddress: myMetaMask,
    asset: asset,
  });
  return balance;
}

function showBalance() {
  getBalance()
    .then((results) => {
      console.log(results);
    })
    .catch((err) => console.error(err));
}
2
  • What's the output supposed to be? Can you try with a more recent node version?
    – Ismael
    Oct 7 '21 at 2:40
  • Unfortunately opensea.js will only work with node v8. As for a return I don’t really know as the documentation isn’t great.
    – itzmrd4
    Oct 7 '21 at 3:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.