Pranshu_Taneja
Pranshu_Taneja

Reputation: 354

Error of Big number while using constructer in solidity

// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.12;

struct account{
        string _name;
        uint _acc_id;
        uint balance;
    }     

contract My_acc{
    account public person;

    constructor(string memory name, uint acc_id, uint _balance){
        person._name = name;
        person._acc_id = acc_id;
        person.balance = _balance;
    }
}

I am trying to pass values to struct variable through constructor But I am getting this following error.

creation of My_acc errored: Error encoding arguments: Error: invalid BigNumber string (argument="value", value="", code=INVALID_ARGUMENT, version=bignumber/5.5.0)

Upvotes: 0

Views: 558

Answers (2)

Pranshu_Taneja
Pranshu_Taneja

Reputation: 354

So guys, I resolved the error. It wasn't actually an error. It was just a silly mistake that I made as a beginner.

SOLUTION: - I wasn't actually passing values to constructor initially. Actually when we add constructor in our contract we basically get a input section with our deploy button automatically (even before actually deploying). which have to be used to pass values before deploying our contract.

enter image description here

Upvotes: 1

RɘN __
RɘN __

Reputation: 53

I tried running the same code and it worked just fine.

Constructor runs only once and that is at the time of deployment. Since you are passing the values to constructor, you should pass the values at the time of deployment.

My reputation does not seem to allow me to upload the image. Please go through the link below.

https://i.sstatic.net/AFBWd.png

Upvotes: 1

Related Questions