1

Here is the script in my deploy.js:

 const main = async () => {
 

  // We get the contract to deploy
  const Transactions = await hre.ethers.getContractFactory("Transactions");
  const transactions = await Transactions.deploy("");

  await greeter.deployed();

  console.log("Greeter deployed to:", greeter.address);
}

const runMain = async() => {
  try {
    await main();
    Process.exit(0);
  } catch (error) {
    console.error(error);
    process.exit(1);
  }
}

runMain();

Here is the script in my hardhat.config.js:

// This is a sample Hardhat task. 
// https://eth-ropsten.alchemyapi.io/v2/Bn5tm9fX90ET1hKwb76lKJB0rzU3JBi2

require("@nomiclabs/hardhat-waffle");


module.exports = {
  solidity: '0.8.0',
  networks: {
    ropsten: {
      url: "https://eth-ropsten.alchemyapi.io/v2/Bn5tm9fX90ET1hKwb76lKJB0rzU3JBi2",
      accounts: ["63b598044c3cce8d656............b7c64beb17eb1687aebbefc5cac8a"]
    }
  }
}

This is my solidity contract script:

// SPDX-License-Identifier: MIT

pragma experimental ABIEncoderV2;

pragma solidity >=0.6.0 <0.9.0;

contract Transactions {
    uint256 transactionCount;

    event Transfer(
        address from,
        address reciever,
        uint256 amount,
        string message,
        uint256 timestamp,
        string keyword
    );

    struct TransferStruct {
        address sender;
        address reciever;
        uint256 amount;
        string message;
        uint256 timestamp;
        string keyword;
    }

    TransferStruct[] transactions;

    function addToBlockchain(
        address payable reciever,
        uint256 amount,
        string memory message,
        string memory keyword
    ) public {
        transactionCount += 1;
        transactions.push(
            TransferStruct(
                msg.sender,
                reciever,
                amount,
                message,
                block.timestamp,
                keyword
            )
        );

        emit Transfer(
            msg.sender,
            reciever,
            amount,
            message,
            block.timestamp,
            keyword
        );
    }

    function getAllTransactions()
        public
        view
        returns (TransferStruct[] memory)
    {
        return transactions;
    }

    function getTransactionCount() public view returns (uint256) {
        return transactionCount;
    }
}

And below is the error message I get anytime I try to compile it:

PS C:\Users\Temitope\Desktop\kredar\smart_contract> npx hardhat run scripts/deploy.js --network ropsten
Error: too many arguments:  in Contract constructor (count=1, expectedCount=0, code=UNEXPECTED_ARGUMENT, version=contracts/5.6.0)
    at Logger.makeError (C:\Users\Temitope\Desktop\kredar\smart_contract\node_modules\@ethersproject\logger\src.ts\index.ts:261:28)
    at Logger.throwError (C:\Users\Temitope\Desktop\kredar\smart_contract\node_modules\@ethersproject\logger\src.ts\index.ts:273:20)
    at Logger.checkArgumentCount (C:\Users\Temitope\Desktop\kredar\smart_contract\node_modules\@ethersproject\logger\src.ts\index.ts:339:18)      
    at ContractFactory.getDeployTransaction (C:\Users\Temitope\Desktop\kredar\smart_contract\node_modules\@ethersproject\contracts\src.ts\index.ts:1218:16)
    at ContractFactory.<anonymous> (C:\Users\Temitope\Desktop\kredar\smart_contract\node_modules\@ethersproject\contracts\src.ts\index.ts:1246:53)    at step (C:\Users\Temitope\Desktop\kredar\smart_contract\node_modules\@ethersproject\contracts\lib\index.js:48:23)
    at ContractFactory.<anonymous> (C:\Users\Temitope\Desktop\kredar\smart_contract\node_modules\@ethersproject\contracts\src.ts\index.ts:1246:53)    at step (C:\Users\Temitope\Desktop\kredar\smart_contract\node_modules\@ethersproject\contracts\lib\index.js:48:23)
    at Object.next (C:\Users\Temitope\Desktop\kredar\smart_contract\node_modules\@ethersproject\contracts\lib\index.js:29:53)
    at fulfilled (C:\Users\Temitope\Desktop\kredar\smart_contract\node_modules\@ethersproject\contracts\lib\index.js:20:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  reason: 'too many arguments:  in Contract constructor',
  code: 'UNEXPECTED_ARGUMENT',
  count: 1,
  expectedCount: 0
}

Please kindly let me know what I'm doing wrong and how to solve it.


after implementing that this is the error i get

PS C:\Users\Temitope\Desktop\kredar\smart_contract> npx hardhat run scripts/deploy.js --network ropsten ReferenceError: greeter is not defined at main (C:\Users\Temitope\Desktop\kredar\smart_contract\scripts\deploy.js:8:3) at processTicksAndRejections (node:internal/process/task_queues:96:5) at runMain (C:\Users\Temitope\Desktop\kredar\smart_contract\scripts\deploy.js:15:5) PS C:\Users\Temitope\Desktop\kredar\smart_contract>

1 Answer 1

0

The error message clearly indicates that your contract expects no argument as a constructor.

Try const transactions = await Transactions.deploy(); in your code.

1
  • The new error you reported says that greeter is not defined in your deploy.js file, but transactions is. In your deploy.js file, simply replace await greeter.deployed(); and console.log("Greeter deployed to:", greeter.address); with await transactions.deployed(); and console.log("Transactions deployed to:", transactions.address); respectively. Commented May 3, 2022 at 8:41

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.