Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error at the end of lesson 5:Error: could not decode result data (value="0x", info={ "method": "retrive", "signature": "retrive()" }, code=BAD_DATA, version=6.11.1) #6513

Open
MohammadArif13 opened this issue Mar 21, 2024 Discussed in #6512 · 1 comment

Comments

@MohammadArif13
Copy link

Discussed in #6512

Originally posted by MohammadArif13 March 21, 2024

const fs = require("fs-extra")
const ethers = require("ethers")
const { JsonRpcProvider } = require("ethers")
require("dotenv").config()

async function main() {
  let provider = new JsonRpcProvider(process.env.RPC_URL)
  let wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider)
  const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf-8")
  const binary = fs.readFileSync(
    "./SimpleStorage_sol_SimpleStorage.bin",
    "utf-8"
  )
  contractFactory = new ethers.ContractFactory(abi, binary, wallet)
  console.log(process.env.RPC_URL)
  console.log(process.env.PRIVATE_KEY, provider)
  console.log("Deploying please wait...")
  const contract = await contractFactory.deploy()
  console.log(contract)
  const signer = wallet.connect(provider)
  const nonce = await signer.getNonce()
 

 console.log(sentTxResponse)

  const currentFavoriteNumber = await contract.retrive()
  console.log(await contract.retrive())
  console.log(`Current Favorite Number: ${currentFavoriteNumber.toString()}`)
  const transactionResponse = await contract.store("12", { nonce: nonce })
  const transactionReceipt = await transactionResponse.wait(1)
  const updatedFavoriteNumber = await contract.retrive()
  console.log(`Updated Favorite Number ${updatedFavoriteNumber}`)
}

main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error)
    process.exit(1)
  })

//    const deploymentReceipt= await contract.waitForDeployment("1") // it imortant line

Hi, on this code i am running into an error: when I am using Alchemy RPC_URL then it gives this error otherwise when I am using ganache there is nothing; Every thing is correct then

Error: could not decode result data (value="0x", info={ "method": "retrive", "signature": "retrive()" }, code=BAD_DATA, version=6.11.1)

below is my RPC_URL but if I am using ganache then there is not any error; all the things are correct then

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

can someone help me?

@bharathkumar369
Copy link

i have got similar problem.. after trying all solutions i have realized that i didnt install the same versions as patrick installed... once check your solc install for 0.8.7-fixed

or

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants