2

问题:Remix 产生奇怪的行为,字符串参数后跟数组参数

复制:

contract ItemMarket is ERC721 {
  struct Item {
    string name;
    uint[3] others;
  }

  Item[] public items;

  function createItem(string _name, uint[6] _others) public {
    uint tokenId = items.push(Item({name: _name, traits:_traits})) - 1;
  }
}

当您使用参数调用 createItem() 时,"hello", [1,2,3]第一个参数将转换为\u0000. 通过 MEW 与合约交互时,具有相同参数的相同函数调用可以正常工作

4

1 回答 1

2

这现在适用于最新版本的 Remix IDE:

pragma solidity 0.5.1;

import "https://github.com/0xcert/ethereum-erc721/src/contracts/tokens/nf-token.sol";

contract ItemMarket is ERC721 {
  struct Item {
    string name;
    uint[3] traits;
  }

  Item[] public items;

  function createItem(string memory name, uint[3] memory traits) public {
    items.push(Item({name:name, traits:traits})) - 1;
  }
}
于 2019-01-21T03:56:44.267 回答