0

When I run:

npx hardhat run --network sepolia scripts/deployFlashLoan.js

I am getting this error:

factory runner does not support sending transactions (operation="sendTransaction", code=UNSUPPORTED_OPERATION, version=6.12.1)
  1. I am not sure why version is 6.12.1
  2. I want to know the correct way to implement getSigner() to solve this problem.

Ethers version in package.json "ethers": "^5.1.3", and I installed ethers with:

npm i [email protected]

deployFlashLoan.js

require('@nomiclabs/hardhat-waffle');
require("@nomiclabs/hardhat-ethers");
require("dotenv").config();
const hre = require("hardhat");

async function main() {
  
        const account = await ethers.getSigners()

        const FlashLoan = await hre.ethers.getContractFactory("FlashLoan");

        const flashLoan = await FlashLoan.deploy("0x012bAC54348C0E635dCAc9D5FB99f06F24136C9A");
   
        await flashLoan.waitForDeployment();

}
main().catch((error) => {
  console.error("Hello5"+error);
  process.exitCode = 1;
});

.env

PRIVATE_KEY="0xMetamask Account"        
SEPOLIA_RPC_URL="https://sepolia.infura.io/v3/<APIKEY>"

hardhat.config.js

require("@nomicfoundation/hardhat-toolbox");
require('@nomiclabs/hardhat-waffle');
require("@nomicfoundation/hardhat-ethers");
require("dotenv").config();
require('hardhat-deploy');

module.exports = {
  defaultNetwork: "sepolia",
  networks: {
    hardhat: {
    },
    sepolia: {
      url: process.env.SEPOLIA_RPC_URL,
      account: [process.env.PRIVATE_KEY]
    }
  },
  solidity: {
    compilers: [
      {
        version: "0.8.25"
      },
      {
        version: "0.8.10"
      }
    ],
    settings: {
      optimizer: {
        enabled: true,
        runs: 200
      }
    }
  },
  paths: {
    sources: "./contracts",
    tests: "./test",
    cache: "./cache",
    artifacts: "./artifacts"
  },
  mocha: {
    timeout: 40000
  }
}

package.json

{
  "name": "hardhat-project",
  "devDependencies": {
    "@ethersproject/abi": "^5.7.0",
    "@ethersproject/providers": "^5.7.1",
    "@nomicfoundation/hardhat-network-helpers": "^1.0.6",
    "@nomicfoundation/hardhat-toolbox": "^2.0.2",
    "@nomiclabs/hardhat-ethers": "^2.2.3",
    "@nomiclabs/hardhat-etherscan": "^3.1.0",
    "@typechain/ethers-v6": "^0.5.1",
    "@typechain/hardhat": "^6.1.3",
    "hardhat": "^2.22.3",
    "hardhat-deploy": "^0.12.4",
    "hardhat-gas-reporter": "^1.0.9",
    "solidity-coverage": "^0.8.2",
    "typechain": "^8.1.0"
  },
  "dependencies": {
    "@aave/core-v3": "^1.16.2",
    "@nomiclabs/hardhat-waffle": "^2.0.6",
    "@openzeppelin/contracts": "^4.7.3",
    "dotenv": "^16.4.5",
    "ethers": "^5.7.2"
  },
  "description": "This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract.",
  "version": "1.0.0",
  "main": "hardhat.config.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

Thanks.

3
  • Please add the deployment script that you’re using. Commented May 9 at 16:20
  • Instead of adding in the comments, it would be much better if you add it in your question by editing the same. As, here, it’s hardly readable. Commented May 10 at 5:09
  • thanks Syed, I have edited the question. Commented May 10 at 5:39

1 Answer 1

0

In your hardhat.config.js file, inside the sepolia object of networks, it should be accounts instead of account , like:

sepolia: {
    url: process.env.SEPOLIA_RPC_URL,
    accounts: [process.env.PRIVATE_KEY]
}

Also, you don't have to use the ethers library explicitly, as the deployment would be handled by the hardhat itself when using hre.ethers.

So, you can just uninstall ethers:

npm uninstall [email protected]

The revised deployment script should be:

const hre = require("hardhat");

async function main() {

    const FlashLoan = await hre.ethers.getContractFactory("FlashLoan");

    const flashLoan = await FlashLoan.deploy("0x012bAC54348C0E635dCAc9D5FB99f06F24136C9A");

    await flashLoan.waitForDeployment();

    console.log("FlashLoan is deployed at address:", await flashLoan.getAddress())

}

main().catch((error) => {
    console.error("Hello5" + error);
    process.exitCode = 1;
});
4
  • change Account to Accounts - Invalid account: #0 for network: sepolia - private key too short, expected 32 bytes. Other errors going off. If I keep Account HH110: Invalid JSON-RPC response received: invalid project id const FlashLoan = await hre.ethers.getContractFactory("FlashLoan"); Commented May 10 at 15:26
  • I think you're using the wallet address instead of private key in your .env file. You can export the private key of your MetaMask account and then use the same in the value of PRIVATE_KEY in your .env file. Commented May 10 at 15:30
  • 1
    hi Syed, thanks for your help. solved the problem. as you said was using Wallet address instead of Private key. Commented May 10 at 16:25
  • Great. You're welcome, Uday. Happy coding! Commented May 10 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.