Error network does not support ens

Running a mocha test with gananche-cli. The test calls a library created with ts. The library deploys a contract. Version "ethers": "^5.0.0-beta.158" test.js 'use strict&#39...

Running a mocha test with gananche-cli. The test calls a library created with ts. The library deploys a contract.

Version

«ethers»: «^5.0.0-beta.158»

test.js

'use strict';
const expect = require('chai').expect;
const ethers = require('ethers')
const ganache = require('ganache-cli');
const MNEMONIC = 'popular stock metal artefact nasty venture oblige horror face glory predict coach'
const { contracts } = require('./../lib/index')

const provider =  new ethers.providers.Web3Provider(
    ganache.provider({
        "mnemonic": MNEMONIC,
        "gasLimit": 8000000,
        "default_balance_ether": 100000000,
    
    })
)

describe('contracts', async function () {
    this.timeout(9000);

    it("Setup accounts", async () => {
        this.DEVELOPER_SIGNER = ethers.Wallet.fromMnemonic(MNEMONIC).connect(provider)
        this.DEVELOPER = await this.DEVELOPER_SIGNER.getAddress()
    })

    it('deploy moloch', async () => {
        const contract = await contracts.moloch.deploy(this.DEVELOPER_SIGNER)
    });
});

index.ts

import { ethers, Signer } from "ethers";
import { abi as molochAbi, bytecode as molochBytecode } from "./compiled_contracts/Moloch.json";

const contract = (abi: any, bytecode: any) => {
    return {
        abi: abi,
        bytecode: bytecode,
        deploy: async (signer: Signer) => {
            return new Promise(async (resolve) => {
                const factory = new ethers.ContractFactory(abi, bytecode, signer)
                const contract = await factory.deploy()
                return resolve(await contract.deployed())
            })
        }
    }
}


export const contracts = {
    moloch: contract(molochAbi, molochBytecode)
}

The line const contract = await factory.deploy() triggers the error `UnhandledPromiseRejectionWarning: Error: network does not support ENS (operation=»ENS», network=»unknown»«. Do i need to deploy ENS in these scenarios?

I am currently trying to build an NFT Marketplace and trying to establish a connection with alchemy-mumbai using JsonRpcProvider. I keep getting this error and can’t figure out what i need to do:

Error when running next.js app

This is my hardhat.config:

require("@nomiclabs/hardhat-waffle");
const fs = require("fs");  // enable file system
const privateKey = fs.readFileSync(".secret").toString().trim();
const url = fs.readFileSync(".secret2").toString().trim();
const url2 = fs.readFileSync(".secret3").toString().trim();


 module.exports = {
  networks: {
    hardhat: {
      
      accountsBalance: "100000000000000000000000"
    },
    mumbai: {

      url: url,
      accounts: [privateKey],
      
    },
    mainnet: {

      url: url2,
      accounts: [privateKey],
      
    }
  },
  solidity: {
    version: "0.8.10",
    settings: {
      optimizer: {
        enabled: true,
        runs: 200
      }
    }
  },
  paths: {
    sources: "./contracts",
    tests: "./test",
    cache: "./cache",
    artifacts: "./artifacts"
  },
  mocha: {
    timeout: 40000
  }
  
}

This is my index.js file:

import {ethers} from 'ethers'; //syn front end to backend smart contracts with ethers
import {useEffect, useState} from 'react'; //keep track of local state and sustain hook functions
import axios from 'axios';  //axios for data fetching
import Web3Modal from 'Web3Modal'; //support metamask/wallet functionality and connectivity
import { nftAddress, nftMarketAddress } from '../config'; // import addresses for NFTix
//import { MoralisProvider } from "react-moralis";
import NFT from "../artifacts/contracts/NFT.sol/NFT.json";
import Market from "../artifacts/contracts/NFTMarket.sol/NFTMarket.json";



// Application Binary Interface (ABI)
// Application Programming interface (API)

// Server1 => API.json <=Server2    See NFT.json

export default function Home() {

  const [nfts, setNfts] = useState([]);
  const [loadingState, setLoadingState] = useState('not-loaded');
  // require("@nomiclabs/hardhat-waffle");
  // const fs = require("fs");
  // const url = fs.readFileSync("../secret2").toString().trim();
  
  useEffect(() => {
    loadNFTs();

  }, []);

  //establish a connection with abi with ethers (Web3Modal also possible)
  async function loadNFTs(){  
    const provider = new ethers.providers.JsonRpcProvider("https://polygon-mumbai.g.alchemy.com/v2/..",);
    const tokenContract = new ethers.Contract(nftAddress, NFT.abi, provider);
    const marketContract = new ethers.Contract(nftMarketAddress, Market.abi, provider);

    //return an array of unsold market items
    const data = await marketContract.fetchMarketItems();

would really appreciate any tips as to why the mumbai network is not found.

Cheers!

Getting the following two errors when I deploy my contract to my local hardhat node:

Error: network does not support ENS (operation=»getAvatar», network=»unknown», code=UNSUPPORTED_OPERATION, version=providers/5.6.5)

Error: network does not support ENS (operation=»lookupAddress», network=»unknown», code=UNSUPPORTED_OPERATION, version=providers/5.6.5)

I’m using ethers, hardhat, and rainbow kit wallet in a next.js app. The rest of my code appears to be working, but I’m still getting these errors in the console on the initial load. Here is my deploy script that I’m running on hardhat:

const fs = require("fs");

async function main() {
  const NFTMarketplace = await hre.ethers.getContractFactory("NFTMarketplace");
  const nftMarketplace = await NFTMarketplace.deploy();
  await nftMarketplace.deployed();
  console.log("nftMarketplace deployed to:", nftMarketplace.address);

  fs.writeFileSync(
    "./config.js",
    `
  export const marketplaceAddress = "${nftMarketplace.address}"
  `
  );
}

main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error);
    process.exit(1);
  });

Discussion on: The Complete Guide to Full Stack Ethereum and EVM Development


Collapse

Expand


emanuel_hodl profile image

If you have this problem at the beginning:

**Is because you’re using an account address instead of the contract address that was prompted in the terminal when you deployed it.

Error:  Error: network does not support ENS (operation="ENS", network="unknown", code=UNSUPPORTED_OPERATION, version=providers/5.1.0)
    at Logger.makeError (index.ts:205)
    at Logger.throwError (index.ts:217)
    at Web3Provider.<anonymous> (base-provider.ts:1407)
    at Generator.next (<anonymous>)
    at fulfilled (base-provider.ts:2)```


Enter fullscreen mode

Exit fullscreen mode


Collapse

Expand


nmassi profile image

or if you leave «your-contract-address» as I forgot to change the const :)
Looks like any string (if it isn’t a contract address) assume it’s an ens domain.


Collapse

Expand


wschwab profile image

I usually get that when I put in a signer instead of the signer’s address. The basic idea is that you’re putting in something other than a hex address, so the compiler’s first thought is that it must be an ENS address (ENS addresses are a way to attach a url-like identifier to an address, like vitalik.eth).

Я использую фреймворк Hardhat и провожу тестирование с контрактом erc20: Я использовал это руководство, чтобы разветвить https://hardhat.org/hardhat- network/docs/guides/forking-other-networks. Я пытаюсь обменять два токена ERC20 в форке основной сети, используя uniswap Я создал пару uniswap для токенов и пытаюсь добавить ликвидность. Вот мой код для тестов. Я уверен, что сделал правильные контракты на токены

require("@nomicfoundation/hardhat-chai-matchers")
const { expect } = require("chai")
const { ethers } = require("hardhat")

//https://unpkg.com/@uniswap/v2-core@1.0.0/build/IUniswapV2Pair.json
const uniswapPairAbi = require("../contracts/IUniswapV2Pair.json")

const uniswapFactoryAbi = require("../contracts/UniswapFactoryAbi.json")

const uniswapRouter02Abi = require("../contracts/IUniswapV2Router02.json")

const daiAbi = require("../contracts/DaiAbi.json")


const uniswapFactoryAddress = "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f"
const uniswapRouterAddress = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D "
describe("Swap", function () {
   let owner
 it("Create Token, Create Pair, Swap", async function () {
       [owner, to] = await ethers.getSigners()

       const MyToken = await ethers.getContractFactory("MyToken", owner)
       const myToken = await MyToken.deploy()
       await myToken.deployed()

       const YourToken = await ethers.getContractFactory("YourToken", owner)
       const yourToken = await YourToken.deploy()
       await yourToken.deployed()

       const factory = await ethers.getContractAt(uniswapFactoryAbi, uniswapFactoryAddress)

       console.log("to ", to.address)
       const pair = await factory.createPair(myToken.address, yourToken.address)


       await expect(pair)
               .to.emit(factory, "PairCreated")
       const swapPairMTYTAddress = await factory.getPair(myToken.address, yourToken.address)

       const wapPairMTYTContract = await ethers.getContractAt(uniswapPairAbi, swapPairMTYTAddress)
       const router02Contract = await ethers.getContractAt(uniswapRouter02Abi, uniswapRouterAddress)
       
       await router02Contract.addLiquidity(myToken.address, yourToken.address,1,1,1,1, owner.address, 12)
      
 });
});

Когда я запускаю тест каски npx. Я получаю такую ​​​​ошибку.

npx hardhat test


  Swap
to  0x70997970C51812dc3A010C7d01b50e0d17dc79C8
    1) Create Token, Create Pair, Swap


  0 passing (6s)
  1 failing

  1) Swap
       Create Token, Create Pair, Swap:
     Error: network does not support ENS (operation="getResolver", network="unknown", code=UNSUPPORTED_OPERATION, version=providers/5.7.2)
      at Logger.makeError (node_modules@ethersprojectloggersrc.tsindex.ts:269:28)
      at Logger.throwError (node_modules@ethersprojectloggersrc.tsindex.ts:281:20)
      at EthersProviderWrapper.<anonymous> (node_modules@ethersprojectproviderssrc.tsbase-provider.ts:1989:20)
      at step (node_modules@ethersprojectproviderslibbase-provider.js:48:23)
      at Object.next (node_modules@ethersprojectproviderslibbase-provider.js:29:53)
      at fulfilled (node_modules@ethersprojectproviderslibbase-provider.js:20:58)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at runNextTicks (node:internal/process/task_queues:65:3)
      at listOnTimeout (node:internal/timers:528:9)
      at processTimers (node:internal/timers:502:7)

Я уверен, что все до addLiquidity работает корректно

2 ответа

Const uniswapRouterAddress = «0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D» пробел не должен быть в конце


0

Max Osad
16 Ноя 2022 в 16:38

В:

const uniswapRouterAddress = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D "

В адресе не может быть пробелов или неопознанных символов. Кроме того, постарайтесь не жестко кодировать свой адрес настолько, насколько это возможно.


0

Diyaa Daoud
16 Ноя 2022 в 23:25

Понравилась статья? Поделить с друзьями:
  • Error netsdk1100 windows is required to build windows desktop applications
  • Error netsdk1004 assets file
  • Error netname deleted
  • Error net err cert date invalid
  • Error net err cert authority invalid