El siguiente código se compila perfectamente y parece funcionar, sin embargo, cuando intento llamar a addTask como:
"elemento1", 1, "i1", 1
He probado todas las variaciones posibles de comillas, paréntesis, corchetes...
Sin embargo me sale el siguiente error:
Transact to taskListContract.addTask con error: Error al codificar argumentos: Error: valor de bytes no válido (arg="", type="string", value="item1")
Cualquier ayuda es muy apreciada.
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
pragma solidity ^0.4.25;
contract Owned {
address public owner;
constructor() public {
owner = msg.sender;
}
/// @notice modifies any function it gets attached to, only allows the owner of the smart contract to execute the function
modifier onlyOwner(){
require(msg.sender == owner);
_;
}
}
contract taskListContract is Owned {
struct task {
bytes iname;
uint16 taskid;
bytes icode;
//replace for a boolean
uint ivalue;
}
uint taskCount;
mapping(bytes => task) taskList;
task[] taskArray;
///function taskListContract() public {
/// log0('hi');
/// }
function addTask(bytes name, uint16 iid, bytes code, uint val) external onlyOwner{
task memory tasknew = task(name, iid ,code, val);
// log0(itemnew);
taskList[code] = tasknew;
taskArray.push(tasknew);
taskCount++;
}
function countItemList() public constant returns (uint count) {
return taskCount;
}
function removeTask(bytes code) external onlyOwner {
delete taskList[code];
taskCount--;
}
function getTask(bytes code) public constant returns (bytes iname, uint val) {
return (taskList[code].iname, taskList[code].ivalue);
}
}