full-blockchain-solidity-course-js icon indicating copy to clipboard operation
full-blockchain-solidity-course-js copied to clipboard

trouble with connecting to sepolia

Open SirHumphreyforreal opened this issue 1 year ago • 6 comments
trafficstars

Lesson

Lesson 1

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

No response

Operating System

Windows

Describe the bug

I replace the RPC_URL from ganache to sepolia in ALCHEMY,and the error came out as timeout ,I dont know how to do ,pls help me !!!!

SirHumphreyforreal avatar Feb 28 '24 14:02 SirHumphreyforreal

code as follows: const ethers = require("ethers"); const fs = require("fs-extra"); require("dotenv").config();

async function main() { const provider = new ethers.providers.JsonRpcProvider(process.env.RPC_URL); const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);

// const encryptedJson = fs.readFileSync("./.encryptedKey.json", "utf8"); // let wallet = new ethers.Wallet.fromEncryptedJsonSync( // encryptedJson, // process.env.PRIVATE_KEY_PASSWORD // ); // wallet = wallet.connect(provider);

const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf8"); const binary = fs.readFileSync( "./SimpleStorage_sol_SimpleStorage.bin", "utf8" ); const contractFactory = new ethers.ContractFactory(abi, binary, wallet); console.log("Deploying,please wait..."); const contract = await contractFactory.deploy(); await contract.deployTransaction.wait(1); console.log(Contract Adress:${contract.address}); //get number const currentFavoriteNumber = await contract.retrieve(); console.log(Current Favorite Number:${currentFavoriteNumber.toString()}); const transactionResponse = await contract.store("900"); const transactionReceipt = await transactionResponse.wait(1); const updatedFavoriteNumber = await contract.retrieve(); console.log(Undated Favorite Number is:${updatedFavoriteNumber}); } //http://127.0.0.1:7545 main() .then(() => process.exit(0)) .catch((error) => { console.error(error); process.exit(1); });

RPC_URL=https://eth-sepolia.g.alchemy.com/v2/q2laUTdKYTZ2Q0im0ang8B8bBPbwbDOS

SirHumphreyforreal avatar Feb 28 '24 14:02 SirHumphreyforreal

please share the termianl output you are getting while running your code

tusharr1411 avatar Feb 29 '24 14:02 tusharr1411

here is the output in terminal Deploying,please wait... Contract Adress:0x7c77C237E343c54398Fa4DfF5edC52D3BcDE4Acf Error: timeout (requestBody="{"method":"eth_getTransactionReceipt","params":["0x6d6346fc22a83fe0d485fc883d79cfe546bfda196b97babdbe884658e3581099"],"id":66,"jsonrpc":"2.0"}", requestMethod="POST", timeout=120000, url="https://eth-sepolia.g.alchemy.com/v2/1sz9_3ooLQRKAltrKOU2XnYcUjvWNPBv", code=TIMEOUT, version=web/5.7.1) at Logger.makeError (/home/sirhumphrey/hh-fcc/ethers-simple-storage/node_modules/@ethersproject/logger/lib/index.js:238:21) at Timeout._onTimeout (/home/sirhumphrey/hh-fcc/ethers-simple-storage/node_modules/@ethersproject/web/lib/index.js:187:35) at listOnTimeout (node:internal/timers:559:17) at processTimers (node:internal/timers:502:7) { reason: 'timeout', code: 'TIMEOUT', requestBody: '{"method":"eth_getTransactionReceipt","params":["0x6d6346fc22a83fe0d485fc883d79cfe546bfda196b97babdbe884658e3581099"],"id":66,"jsonrpc":"2.0"}', requestMethod: 'POST', timeout: 120000, url: 'https://eth-sepolia.g.alchemy.com/v2/1sz9_3ooLQRKAltrKOU2XnYcUjvWNPBv' }

SirHumphreyforreal avatar Mar 01 '24 17:03 SirHumphreyforreal

please this line to wait for the block confirmation :

  await contract.deploymentTransaction().wait(1);

tusharr1411 avatar Mar 04 '24 21:03 tusharr1411

its been a long time to bring this up again,occupied by something else recently and I wanna say thank you for ur help but I did as u said, it turned out still the same the errors are as follow: Deploying contract... Deployed contract to:0x794CF5504cc7b1452b1EB354a9cfCa42c0140304 Waiting for block confirmations... Verifying contract... UnexpectedError: An unexpected error occurred during the verification process. Please report this issue to the Hardhat team. Error Details: Connect Timeout Error at Etherscan.isVerified (/home/sirhumphrey/hh-fcc/hardhat-simple-storage-fcc/node_modules/@nomicfoundation/hardhat-verify/src/internal/etherscan.ts:126:13) at processTicksAndRejections (node:internal/process/task_queues:96:5) at SimpleTaskDefinition.action (/home/sirhumphrey/hh-fcc/hardhat-simple-storage-fcc/node_modules/@nomicfoundation/hardhat-verify/src/internal/tasks/etherscan.ts:101:24) at Environment._runTaskDefinition (/home/sirhumphrey/hh-fcc/hardhat-simple-storage-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:358:14) at Environment.run (/home/sirhumphrey/hh-fcc/hardhat-simple-storage-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:191:14) at SimpleTaskDefinition.action (/home/sirhumphrey/hh-fcc/hardhat-simple-storage-fcc/node_modules/@nomicfoundation/hardhat-verify/src/index.ts:284:9) at Environment._runTaskDefinition (/home/sirhumphrey/hh-fcc/hardhat-simple-storage-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:358:14) at Environment.run (/home/sirhumphrey/hh-fcc/hardhat-simple-storage-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:191:14) at verify (/home/sirhumphrey/hh-fcc/hardhat-simple-storage-fcc/scripts/deploy.js:31:9) at main (/home/sirhumphrey/hh-fcc/hardhat-simple-storage-fcc/scripts/deploy.js:15:9) Current Value is: 0 Updated Value is: 7 Done in 38.65s. it is a little bit different compared to the way it was before ,but I assume its because hardhat or sepolia stuff ,not the code itself I wanna get help pls

SirHumphreyforreal avatar May 01 '24 14:05 SirHumphreyforreal

As you can see in your terminal output the contract is deplpyed successfully, Now the problem is with your etherscan verification. Please share your latest code.

tusharr1411 avatar May 01 '24 15:05 tusharr1411