Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solidity Remix: passing multiple bytes32 type arguments

How to pass multiple arguments in Remix? No matter which way I pass the arguments to the setOrder function, I get different errors:

SyntaxError: Unexpected token in JSON at position 1

Error: invalid bytes32 value (arg=undefined, type="string", value="abc")

This is the code:

pragma solidity ^0.4.11;

contract MyContract {
    bytes32 public customer;
    bytes32 public location;
    bytes32 public product;
    bytes32 public reorderAmount;
    bytes32 public usdLitrePrice;
    bytes32 public usdTotalPrice;
    bytes32 public timestamp;

    function setOrder(bytes32 _customer, bytes32 _location, bytes32 _product, bytes32 _reorderAmount, 
                    bytes32 _usdLitrePrice, bytes32 _usdTotalPrice, bytes32 _timestamp) public {

        customer = _customer;
        location = _location;
        product = _product;
        reorderAmount = _reorderAmount;
        usdLitrePrice = _usdLitrePrice;
        usdTotalPrice = _usdTotalPrice;
        timestamp = _timestamp;
    }

    function getOrder() public constant returns (bytes32, bytes32, bytes32, bytes32, bytes32, bytes32, bytes32) {
        return (customer, location, product, reorderAmount, usdLitrePrice, usdTotalPrice, timestamp);
    }
}
like image 923
baermathias Avatar asked Jan 28 '23 03:01

baermathias


1 Answers

Here is the solution:

You can't use empty space after a comma ,

You can't use ' --> instead use "

You have to use hex 0x...

Example:

"0x123","0x123","0x123","0x123","0x123","0x123","0x123"

like image 72
baermathias Avatar answered Feb 11 '23 09:02

baermathias