Kann kein Byte ohne Fehler an eine Funktion übergeben

Der folgende Code lässt sich perfekt kompilieren und scheint zu funktionieren, aber wenn ich versuche, addTask wie folgt aufzurufen:

"Element1", 1, "i1", 1

Ich habe jede mögliche Variation von Anführungszeichen, Klammern ...

Allerdings bekomme ich folgenden Fehler:

transact to taskListContract.addTask errored: Error encoding arguments: Error: invalid bytes value (arg="", type="string", value="item1")

Jede Hilfe wird sehr geschätzt.

/**
 * @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);
    }
}

Antworten (1)

Um die Funktion mit bytesParameter aufzurufen, müssen Sie den Parameter im Hexadezimalformat übergeben

Geben Sie hier die Bildbeschreibung ein