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

xgocn xgocn 提出于 2022-01-11 00:19 4867 浏览

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; 就可以支持了

Tiny熊

擅长:智能合约,以太坊 · 采纳率 33% · 回答于 2022-01-11 08:53

其它 0 个回答

写回答

你需要登录后才可以回答问题,登录