0

when I run this code I get the error "call to Voting.candidates errored: Error encoding arguments: Error: invalid BigNumber string (argument="value", value="", code=INVALID_ARGUMENT, version=bignumber/5.0.8)" anybody know how to fix this or what is means??

contract Voting {
    
    ///@dev keeps track of the voter candidates' info
    struct VoterCandidate {
        string voterName;
        uint voterAge;
    }
    
    ///@dev keeps track of all the candidates
    VoterCandidate[] public candidates;

    ///@dev creates a new "VoterCandidate" and adds a the candidate to the array of candidates
    function candidateRegistration(string memory _voterName, uint _voterAge) public {
        VoterCandidate memory newCandidate;
        newCandidate.voterName = _voterName;
        newCandidate.voterAge = _voterAge;
        candidates.push(newCandidate);
    }
    
}
0

Are you compiling in Remix or with something like Truffle? What does your function call look like? If you are calling the function with javascript/web3 it could potentially be that you're not using '' around the number and instead passing it in as an integer. You might be doing

Voting.methods.candidateRegistration("billy", 25);

as opposed to

Voting.methods.candidateRegistration("billy",'25');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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