首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Solidity :传递多个bytes32类型参数

Solidity :传递多个bytes32类型参数
EN

Stack Overflow用户
提问于 2018-05-10 22:11:25
回答 1查看 7.5K关注 0票数 5

如何在Remix中传递多个参数?无论以哪种方式将参数传递给setOrder函数,我都会得到不同的错误:

SyntaxError:位置1处JSON中的意外令牌 错误:无效的bytes32值(arg=undefined,type="string",value="abc")

这是代码:

代码语言:javascript
复制
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);
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-05-10 22:45:21

以下是解决办法:

你不能在逗号后使用空空间,

您不能使用' ->而是使用"

您必须使用十六进制0x...

示例:

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

票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50282211

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档