Below is the prograame in solidity I wrote which assigns value to elements of an array.
pragma solidity 0.8.16 ;
contract arr
{
uint i = 0 ;
people[] public person ;
struct people
{
uint256 num ;
string name ;
}
function plus(string memory naam , uint256 nu) public
{
person[i].num = nu ;
person[i].name = naam ;
i++ ;
}
}
Instead of push function I want to put values like this . While compilation and deploying no error comes however when I call this function then this error shows :-
It reads:-
The transaction has been reverted to the initial state.
Note: The called function should be payable if you send value and the value you send should be less than your current balance.
Debug the transaction to get more information.
I want to know what I am doing wrong , and why is it asking me to make the function payable.
Thank You