Sadaf Sagheer
Sadaf Sagheer

Reputation: 11

TypeError: Invalid URL : while deploying smart contract i am getting this error

C:\Users\hp\twitter_clone\server>npx hardhat run scripts/deploy.js --network rinkeby npm WARN config global --global, --local are deprecated. Use --location=global instead. TypeError: Invalid URL at new NodeError (node:internal/errors:372:5) at URL.onParseError (node:internal/url:553:9) at new URL (node:internal/url:629:5) at new HttpProvider (C:\Users\hp\twitter_clone\server\node_modules\hardhat\src\internal\core\providers\http.ts:51:17) at createProvider (C:\Users\hp\twitter_clone\server\node_modules\hardhat\src\internal\core\providers\construction.ts:118:23) at C:\Users\hp\twitter_clone\server\node_modules\hardhat\src\internal\core\runtime-environment.ts:82:28 at getRealTarget (C:\Users\hp\twitter_clone\server\node_modules\hardhat\src\internal\util\lazy.ts:112:22) at Object.get (C:\Users\hp\twitter_clone\server\node_modules\hardhat\src\internal\util\lazy.ts:185:26) at createProviderProxy (C:\Users\hp\twitter_clone\server\node_modules@nomiclabs\hardhat-ethers\src\internal\provider-proxy.ts:25:19) at C:\Users\hp\twitter_clone\server\node_modules@nomiclabs\hardhat-ethers\src\internal\index.ts:35:27 { input: 'gGu01voSv52VJ6Ps9hYdffxEdgmCh-_BB', code: 'ERR_INVALID_URL' }

Upvotes: 0

Views: 1503

Answers (1)

icebox
icebox

Reputation: 105

I encountered the same issue and after googling around, this post combined with yours gave me some hint that the createProvider is trying to get all of the necessary information to interact with the chain. Then I checked all of the variables defined in .env and see if any of them are missing. For me, the private key was missing. For yours, it might be caused by the API key invalid. You need the following info to make it work.

  • URL: from alchemy or whatever service you are using
  • API_KEY: same as above
  • PRIVATE_KEY: your wallet private key

Upvotes: 0

Related Questions