I wanna create a system allowing a company to save several data in the contract, and at the same time many companies can save data in this system.
So I create the mapping of struct, and there's array to allow several data correspond to their index stored in one struct.
But when I deployed it on Remix, and wanna stored with function saveStandard, it appears the following error:
transact to Storage.saveStandard errored: Error encoding arguments: Error: invalid BigNumber string (argument="value", value="0.2", code=INVALID_ARGUMENT, version=bignumber/5.4.1)
what happened to my following code?
pragma solidity >=0.7.0 <0.9.0;
contract Storage{
struct UserInfo {
uint index;
string[] time;
string[] source;
uint[] emission;
}
mapping (string => UserInfo) public users;
function saveStandard(uint input_material, uint weight, string memory input_time, string memory input_source)
public returns (string memory, uint, uint, string memory){
uint id = users[input_source].index + 1;
users[input_source].index = id;
users[input_source].time[id] = input_time;
uint Combustion = weight * input_material;
uint Process = weight * input_material;//input_material is the emission factor
users[input_source].emission[id] = Combustion + Process;
return (input_source, Combustion, Process, input_time);
}
function search(string memory input_source) public view returns (uint, string memory) {
uint id = 0;
while (id <= users[input_source].index) {
id += 1;
return (users[input_source].emission[id], users[input_source].time[id]);
}
}
}