gpt4 book ai didi

arguments - Solidity 混音 : passing multiple bytes32 type arguments

转载 作者:行者123 更新时间:2023-12-02 22:32:37 26 4
gpt4 key购买 nike

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

SyntaxError: Unexpected token in JSON at position 1

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

这是代码:

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);
}
}

最佳答案

解决方案如下:

逗号后不能使用空格,

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

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

示例:

“0x123”,“0x123”,“0x123”,“0x123”,“0x123”,“0x123”,“0x123”

关于arguments - Solidity 混音 : passing multiple bytes32 type arguments,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50282211/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com