0

It`s my event.

event Transfer(address sender, address receiver, string[] denoms, uint256[] amounts);

And I view an Transfer event with watch() function, It`s the result.

{
  address: "0x33036fcbd3413f70fbdf771a646ab7457b26d5e1",
  args: {
    amounts: [10000, 10000],
    denoms: ["", ""],
    receiver: "0x905319c93683eb3203437d21900d9bdda487f65e",
    sender: "0xb85618eac4df82118512c3ff9eca48a61a858fdb"
  },
  blockHash: "0x894fa661c7cd4fde5de2d32b9fc8732c2a58e28e93d9c8280fa7ebd8c2ffed1f",
  blockNumber: 6291,
  event: "Transfer",
  logIndex: 0,
  removed: false,
  transactionHash: "0x61b9edbc223d71accb0a223a5d7b867782f464607a41693239964f03c1def4a3",
  transactionIndex: 0
}

Maybe... a string list isn`t available as an argument. Is it right?

0

Yes, you are right. A string list ( string[] ) cannot be used. But, uint256[] is possible.

The problem you are seeing this is because Solidity does not yet support two levels of dynamic arrays i.e., string[] while it requires two levels of dynamic arrays (string is a dynamic array itself).

If you still want to use it, you just need to add an additional experimental line at the top of your code.

pragma experimental ABIEncoderV2;

Then in the event, provide the number of values in string[] you want to pass. Eg. you want to pass a string list of 2 values, so write string[2]

event Transfer(address sender, address receiver, string[2] denoms, uint256[] amounts);

And then fire your event like this:

emit Transfer(addr_sender, add_receiver, ["str1", "str2"], amnt)

Note: This is an experimental feature so it's not suggested to use it on live deployments.

Also, always try to first compile your contract on Remix and then on your project.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.