getCode() not returning bytecode; "Request-Rate Exceeded" notice on hardhat test running on localhost #2932
Replies: 4 comments 12 replies
-
This line will connect to a default set of providers, backed by INFURA, Alchemy, etc. which is why you are getting that warning, as you are not providing your own API keys and using the community-provided resources by those services: let provider = ethers.getDefaultProvider(); |
Beta Was this translation helpful? Give feedback.
-
I don’t want to use the HRE because ultimately I want to deploy this to Google Cloud functions. I’d like to figure out how to do this with ‘unextended’ ethers.js
From: soham ***@***.***>
Reply-To: "ethers-io/ethers.js" ***@***.***>
Date: Thursday, April 28, 2022 at 6:25 AM
To: "ethers-io/ethers.js" ***@***.***>
Cc: Josh Kramer ***@***.***>, Author ***@***.***>
Subject: Re: [ethers-io/ethers.js] getCode() not returning bytecode; "Request-Rate Exceeded" notice on hardhat test running on localhost (Discussion #2932)
As I mentioned, I'm running this inside a hardhat test, which runs on a locally hosted hardhat node
You should use hre.ethers.provider to get a ethers provider (which extends the type ethers.providers.Provider).
—
Reply to this email directly, view it on GitHub<#2932 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ACCIEBLWQUCSTPCCXDWSM23VHKGT3ANCNFSM5UNHYCJQ>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Thanks. I see that when you a run a hardhat test without the network flag (which means its running on a hardhat-created node on the localmachine), getDefaultProvider().network return "homestead". I had thought it would return the local hardhat created network node provider. I don't see a mechanism to get a handle on hardhat's local testing provider, but I will keep searching. |
Beta Was this translation helpful? Give feedback.
-
Yeah, I've been getting that sort of message from both you folks and hardhat (Nothing to do with hardhat, try ethers). It's quite confusing for newbieish: For example, if I want to get a handle on the abi for a simple contract like this:
If I attempt to get the abi in hardhat from the artifacts hardhat creates as follows:
That yields:
But if I try to get the ABI directly from the contract using ethers (using
So which one of these is the "real" abi? (The one I can use on etherscan to validate when it asks for ABI), or the one I could use to get a handle to a deployed contract instance using contract = `new ethers.Contract(address, abi, signer)? the problem is that while hardhat is very handy for development of my smart contracts, I dont want to have deploy it on the front end or backend of my dapp, but the fact that they "extend" ethers.js with all kinds of things that specific only to hardhat, and their "artfacts" including bytecode and apparently abi's can't be used outside of the hardhat context makes life difficult and hard to know which is "real ethers" and what is a hardhat specific thing. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Ethers Version
8.5.0
Search Terms
No response
Describe the Problem
Running this test on hardhat
produced this warning but completed successfully
which seems weird because the test is running on the local hardhat node.
It also returns only '0x' to the
getCode
request in penultimate line of test. It doesnt seem like these two errors are related but I"m unsure. The bytecode is big.Code Snippet
No response
Contract ABI
No response
Errors
No response
Environment
No response
Environment (Other)
No response
Beta Was this translation helpful? Give feedback.
All reactions