【问题标题】:web3j - TypeReference for event with string parameterweb3j - 带有字符串参数的事件的 TypeReference
【发布时间】:2021-08-14 14:31:43
【问题描述】:

假设我的 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

【问题讨论】:

    标签: ethereum solidity web3-java


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-25
      • 2015-12-07
      • 1970-01-01
      • 1970-01-01
      • 2015-07-03
      相关资源
      最近更新 更多