smartcontractkit / full-blockchain-solidity-course-py

Ultimate Solidity, Blockchain, and Smart Contract - Beginner to Expert Full Course | Python Edition
MIT License
10.76k stars 2.9k forks source link

the struct cannot be properly made by push #1699

Closed dankorea closed 2 years ago

dankorea commented 2 years ago

I am a newbie. I almost copied the codes from Lesson1 video and when I deployed and input "string name" and "favoriteNumber" in "addPerson" button box and tested it. Well, the "people" changed nothing and showed below error: call to SimpleStorage.people errored: Error encoding arguments: Error: invalid BigNumber string (argument="value", value="", code=INVALID_ARGUMENT, version=bignumber/5.5.0)

can anyone help me out? It's my first day on solidity, thx, fams

raw codes are here: /////////////////////////////////////// //SPDX-License-Identifier: MIT

pragma solidity ^0.6.8;

contract SimpleStorage { //initial will be zero uint256 favoriteNumber;

struct People{
    uint256 favoriteNumber;
    string name;
}

//People public person = People({favoriteNumber:2, name:"Patrick"});

People[] public people;

function store(uint256 _favoriteNumber) public {
    favoriteNumber = _favoriteNumber;
}
//view,pure only read off the chain
function retrieve() public view returns(uint256){
    return favoriteNumber;
}

function addPerson(string memory _name,uint256 _favoriteNumber) public {
    people.push(People(_favoriteNumber,_name));
}

}

dankorea commented 2 years ago

found answer somewhere, the people index should be filled with 0