3 solidity的事件中,可以返回结构体吗?

contract NoteContract {//合约声明 //字典类型: mapping,notes是一个键值对,其Key为发布者地址,类型为address,值为每个发布者发布的内容,类型为string[] mapping(address => NoteRecord) public notes;

//constructor() public { }

event NewNote(address spender, NoteRecord note); // event NewNote(address, string note); event ModifyNote(address spender, uint256 index); // event ModifyNote(address, uint index);

struct NoteRecord { uint256 noteId; string noteContent; uint256 chainTime; }

}

收到如下提示:

===========================
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\NoteContract.sol
> Compiling .\contracts\NoteContract.sol

project:/contracts/NoteContract.sol:10:36: TypeError: This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
    event NewNote(address spender, NoteRecord noteDE);
请先 登录 后评论

最佳答案 2022-01-11 09:42

在文件头, 加上 pragma experimental ABIEncoderV2; 就可以支持了

请先 登录 后评论

其它 0 个回答

  • 1 关注
  • 1 收藏,2987 浏览
  • xgocn 提出于 2022-01-11 00:19