You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an error I'm doing an inventory program that saves data and should save the data in the blockchain, but for some reason I get an error when I try to pass the parameters in the function that is meant to add data I get the error Error: Invalid number of parameters for "addData". Got 1 expected 4!
THIS IS THE CODE I HOPE YOU CAN HELP ME I'm learning alone with youtube:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
contract Menu {
//Voy a crear un mapping que guarde valores de productos y luego mostrarlos en pantalla
//Los valores principales son Id, nombre, cantidad y precio
//Creo una variable contador que tendra el valor del ID, esta variable esta afuera del struct
uint public contador = 0;
constructor (){
addData(1.0, "Primer tarea de ejemplo", 27589.0, 678.0);//AQUI ESTA EL PROBLEMA
}
//Voy a crear un array que guarde esos datos la ID (filas) sera un valor uint
// y lo Menu_BDs atributos (columnas) seran los datos del struct
//El nombre del mapping sera Manu_BD
mapping(uint256=>Productos) public Menu_BD;
//Funcion para agregar datos
function addData(uint256 _id, string memory _nombre, uint _cantidad, uint _precio) public{
//Aqui necesito generar el Key automaticamente con un contador
//e ir llenando con datos
//El contador no se pasa como parametro
Menu_BD[contador] = Productos(_id, _nombre, _cantidad, _precio);
//al pasar como parametro el id le indicas que el ID ira por defecto
contador ++;
}
}
The text was updated successfully, but these errors were encountered:
I have an error I'm doing an inventory program that saves data and should save the data in the blockchain, but for some reason I get an error when I try to pass the parameters in the function that is meant to add data I get the error Error: Invalid number of parameters for "addData". Got 1 expected 4!
THIS IS THE CODE I HOPE YOU CAN HELP ME I'm learning alone with youtube:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
contract Menu {
//Voy a crear un mapping que guarde valores de productos y luego mostrarlos en pantalla
//Los valores principales son Id, nombre, cantidad y precio
//Creo una variable contador que tendra el valor del ID, esta variable esta afuera del struct
uint public contador = 0;
constructor (){
addData(1.0, "Primer tarea de ejemplo", 27589.0, 678.0);//AQUI ESTA EL PROBLEMA
}
struct Productos{
uint256 id;
string nombre;
uint cantidad;
uint precio;
}
//Voy a crear un array que guarde esos datos la ID (filas) sera un valor uint
// y lo Menu_BDs atributos (columnas) seran los datos del struct
//El nombre del mapping sera Manu_BD
mapping(uint256=>Productos) public Menu_BD;
//Funcion para agregar datos
function addData(uint256 _id, string memory _nombre, uint _cantidad, uint _precio) public{
//Aqui necesito generar el Key automaticamente con un contador
//e ir llenando con datos
//El contador no se pasa como parametro
Menu_BD[contador] = Productos(_id, _nombre, _cantidad, _precio);
//al pasar como parametro el id le indicas que el ID ira por defecto
contador ++;
}
}
The text was updated successfully, but these errors were encountered: