6

When i try to deploy my example contract it gives me the error creation of Auction errored: Error encoding arguments: Error: invalid BigNumber string (argument="value", value="", code=INVALID_ARGUMENT, version=bignumber/5.0.8)

// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.5.2;


contract Auction{
    mapping(address=> uint)public bids;

    struct Car{
        string description;
        uint value;
        uint built_year;
    }
    
    Car public private_car;
    mapping(address=> Car) public cars;
    
    
    constructor(string memory _description, uint _value, uint _built_year) public{
    private_car.description = _description;
    private_car.value = _value;
    private_car.built_year = _built_year;
    
       cars[msg.sender] = private_car;
    }
    
    function bid() payable public{
        bids[msg.sender] = msg.value;
    }
    
    
}

Why it gives this error when i pass nothing in the constructor? It works fine if i pass something in the constructor at the time of deployment.

4
  • 1
    The problem is in the deployer, not in your smart contract code. Commented Feb 1, 2021 at 9:24
  • please post the transaction hash
    – Nulik
    Commented Feb 1, 2021 at 16:02
  • @MikkoOhtamaa what do you mean by that? i am deploying on Remix JavaScript VM with the same account that i'm using while passing the parameters on the constructor Commented Feb 1, 2021 at 20:09
  • @Nulik I am not getting the transaction hash. all i am getting in the logs is the error "creation of Auction errored: Error encoding arguments: Error: invalid BigNumber string (argument="value", value="", code=INVALID_ARGUMENT, version=bignumber/5.0.8)" Commented Feb 1, 2021 at 20:10

3 Answers 3

6

If you have a constructor with arguments and you don't have an empty constructor defined, you have to give the arguments when deploying the contract. If you try to deploy without arguments you get an error - Remix just seems to give a bit strange error.

1

At the time of deployment of your contract in Remix, you get a drop-down option where you need to pass all the values defined in the constructor. This will be a predefined value for your contract.

 constructor(string memory _description, uint _value, uint _built_year) public{
    private_car.description = _description;
    private_car.value = _value;
    private_car.built_year = _built_year;
    
       cars[msg.sender] = private_car;
    }

In your case, you need to provide these values:

_description, _value, _built_year

0

You're probably leaving out some required part of the input, i.e. the function expects 3 fiels of data, and you're providing only 2.

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.