Coder Social home page Coder Social logo

Comments (6)

SirHumphreyforreal avatar SirHumphreyforreal commented on June 3, 2024

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

from full-blockchain-solidity-course-js.

tusharr1411 avatar tusharr1411 commented on June 3, 2024

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

from full-blockchain-solidity-course-js.

SirHumphreyforreal avatar SirHumphreyforreal commented on June 3, 2024

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'
}

from full-blockchain-solidity-course-js.

tusharr1411 avatar tusharr1411 commented on June 3, 2024

please this line to wait for the block confirmation :

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

from full-blockchain-solidity-course-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.