0

I try to connect to mumbai testnet in javascript. I don't want to use alchemy, infura or something like this, but want to connect drectly. I already have deployed a smart contract to mumbai-testnet.

I try the following:

const provider = new ethers.providers.JsonRpcProvider(process.env.URL);

where my Url in the .env file is:

URL=https://rpc-mumbai.maticvigil.com/

everything works so far, I even get access to my wallet using:

const wallet = new ethers.Wallet(private_key, provider)

now I am connecting my smart contract like this:

const contract = new ethers.Contract(deployed_contact_address, abi, provider);

I think this also works so far, if I use console.log to show the contract, I can see the functions included in smart contract. But if I want to access the functions like this:

var out_min = contract.getAmountOutMin(dict_routers.get("uniswap_v2"), dict_bA.get("MATIC"), dict_tok.get("DAI"), 100);

I get an error:

node_modules\@ethersproject\logger\lib\index.js:233
        var error = new Error(message);
                    ^

Error: network does not support ENS (operation="getResolver", network="maticmum", code=UNSUPPORTED_OPERATION, version=providers/5.6.8)
    at Logger.makeError (C:\Users\danis\arbitrage_bot\node_modules\@ethersproject\logger\lib\index.js:233:21)
    at Logger.throwError (C:\Users\danis\arbitrage_bot\node_modules\@ethersproject\logger\lib\index.js:242:20)
    at JsonRpcProvider.<anonymous> (C:\Users\danis\arbitrage_bot\node_modules\@ethersproject\providers\lib\base-provider.js:2305:36)
    at step (C:\Users\danis\arbitrage_bot\node_modules\@ethersproject\providers\lib\base-provider.js:48:23)
    at Object.next (C:\Users\danis\arbitrage_bot\node_modules\@ethersproject\providers\lib\base-provider.js:29:53)
    at fulfilled (C:\Users\danis\arbitrage_bot\node_modules\@ethersproject\providers\lib\base-provider.js:20:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  reason: 'network does not support ENS',
  code: 'UNSUPPORTED_OPERATION',
  operation: 'getResolver',
  network: 'maticmum'
}

Can someone tell me, what is going wrong here? I don't know what to do anymore. Thank you!

2
  • Without knowing the contract you are calling and what your input looks like, it is very hard to tell. I would guess that one of the addresses has an incorrect format (should be an address, but is a string) and thus is interpreted as ENS Aug 16, 2022 at 20:27
  • Thanks for your answer. How can I check this? How can I change the string to an address?
    – Dani S
    Aug 16, 2022 at 21:03

2 Answers 2

0

Your address is coming up as a string. To try a fix, just paste the address (e.g. "0x12345..." into the field where the variable name is

If that's your issue, its just a javascript issue on reading the env/variable correctly

3
  • I replaced all variable names with the addresses, but it is still not working
    – Dani S
    Aug 17, 2022 at 14:27
  • are the addresses in quotes?
    – thefett
    Aug 17, 2022 at 14:54
  • I tried with quotes and without quotes
    – Dani S
    Aug 17, 2022 at 15:55
0

If you want to write to the smart contract you have to sign it with a signer argument..hope it will help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.