0

假设我的 Solidity 智能合约中有以下事件:

event Buy(address buyer, string itemName);

我正在尝试在web3j Java 库中构造相应的事件。这就是我所做的:

public static final Event BUY = new Event(
  "Buy", Arrays.<TypeReference<?>>asList(
    new TypeReference<Address>(false) {}, // address buyer
    new TypeReference<String>(false) {}, // string itemName
  )
);  

但是,它给了我错误:

Bound mismatch: The type String is not a valid substitute for the bounded parameter <T extends Type> of the type TypeReference<T>

我应该使用哪种类型而不是String

4

1 回答 1

0

String返回类型替换为Utf8String. 这将解决问题。

于 2021-12-11T09:15:47.263 回答