Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

Error: PollingBlockTracker - encountered an error while attempting to update latest block: undefined #186

Open
FantasyGameFoundation opened this issue Feb 16, 2022 · 3 comments

Comments

@FantasyGameFoundation
Copy link

Hi, I'm imitating creation-accessories to write an erc1155's factory contract, both my erc1155 contract and the factory contract have been deployed successfully, but my initial_sale script is not working (with node ./script/initial_sale.js). Below is my initial_sale script and error message.

initial_sale.js

require('dotenv').config();
const opensea = require('opensea-js')
const { WyvernSchemaName } = require('opensea-js/lib/types')
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 = process.env.MNEMONIC
const INFURA_KEY = process.env.INFURA_KEY
const FACTORY_CONTRACT_ADDRESS = process.env.FACTORY_CONTRACT_ADDRESS
const OWNER_ADDRESS = process.env.OWNER_ADDRESS
const NETWORK = process.env.NETWORK
const API_KEY = process.env.API_KEY || '' // API key is optional but useful if you're doing a high volume of requests.

// Lootboxes only. These are the *Factory* option IDs.
// These map to 0, 1, 2 as LootBox option IDs, or 1, 2, 3 as LootBox token IDs.
const FIXED_PRICE_OPTION_IDS = ['0', '1', '2']
const FIXED_PRICES_ETH = [0.1, 0.2, 0.3]
const NUM_FIXED_PRICE_AUCTIONS = [1, 1, 1] // [2034, 2103, 2202];

if (!MNEMONIC || !INFURA_KEY || !NETWORK || !OWNER_ADDRESS) {
  console.error(
    'Please set a mnemonic, infura key, owner, network, API key, nft contract, and factory contract address.'
  )
  return
}

if (!FACTORY_CONTRACT_ADDRESS) {
  console.error('Please specify a factory contract address.')
  return
}

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

const mnemonicWalletSubprovider = new MnemonicWalletSubprovider({
  mnemonic: MNEMONIC,
  baseDerivationPath: BASE_DERIVATION_PATH,
})
const network = 'rinkeby'
const infuraRpcSubprovider = new RPCSubprovider({
  rpcUrl: 'https://rinkeby.infura.io/v3/66cad04b18f349a1ae1aafe147148920',
})

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

const seaport = new OpenSeaPort(
  providerEngine,
  {
    networkName: 'rinkeby',
    apiKey: API_KEY,
  },
  (arg) => console.log(arg)
)

async function main() {
  // Example: many fixed price auctions for a factory option.
  for (let i = 0; i < FIXED_PRICE_OPTION_IDS.length; i++) {
    const optionId = FIXED_PRICE_OPTION_IDS[i]
    console.log(`Creating fixed price auctions for ${optionId}...`)
    const numOrders = await seaport.createFactorySellOrders({
      assets: [
        {
          tokenId: optionId,
          tokenAddress: FACTORY_CONTRACT_ADDRESS,
          // Comment the next line if this is an ERC-721 asset (defaults to ERC721):
          schemaName: WyvernSchemaName.ERC1155,
        },
      ],
      // Quantity of each asset to issue
      quantity: 1,
      accountAddress: OWNER_ADDRESS,
      startAmount: FIXED_PRICES_ETH[i],
      // Number of times to repeat creating the same order for each asset. If greater than 5, creates them in batches of 5. Requires an `apiKey` to be set during seaport initialization:
      numberOfOrders: NUM_FIXED_PRICE_AUCTIONS[i],
    })
    console.log(`Successfully made ${numOrders} fixed-price sell orders!\n`)
  }
}

main().catch((e) => console.error(e))

error message

/Users/diode/Desktop/FantasyGameFoundation/FGF_SmartContract/node_modules/eth-block-tracker/src/polling.js:51
        const newErr = new Error(`PollingBlockTracker - encountered an error while attempting to update latest block:\n${err.stack}`)
                       ^
Error: PollingBlockTracker - encountered an error while attempting to update latest block:
undefined
    at PollingBlockTracker._performSync (/Users/diode/Desktop/FantasyGameFoundation/FGF_SmartContract/node_modules/eth-block-tracker/src/polling.js:51:24)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
@FantasyGameFoundation
Copy link
Author

FantasyGameFoundation commented Feb 16, 2022

I changed to alchemy url, and the error I got is the following.

FetchError: request to https://testnets-api.opensea.io/api/v1/asset/0x09d4df02227352D723160a31Ea8Bd6003eDFEA27/0/? failed, reason: connect ETIMEDOUT 162.220.12.226:443
    at ClientRequest.<anonymous> (/Users/diode/Desktop/FantasyGameFoundation/FGF_SmartContract/node_modules/node-fetch/lib/index.js:1491:11)
    at ClientRequest.emit (node:events:520:28)
    at TLSSocket.socketErrorListener (node:_http_client:442:9)
    at TLSSocket.emit (node:events:520:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  type: 'system',
  errno: 'ETIMEDOUT',
  code: 'ETIMEDOUT'
}

I can not even ping the IP address 162.220.12.226 in the error message.

@d-s-i
Copy link

d-s-i commented Feb 21, 2022

Did you solved this ? I get the same error and tried many different providers like Alchemy, Infura, Moralis, none solved the error

@FantasyGameFoundation
Copy link
Author

Did you solved this ? I get the same error and tried many different providers like Alchemy, Infura, Moralis, none solved the error
I was caused by network reasons, and it was normal to switch to my cloud server. You can try to ping testnets-api.opensea.io.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants