简体   繁体   English

Web3j Android Java Solidity包装器错误

[英]Web3j Android java solidity wrapper errors

Trying to use web3j to invoke some functions in a contract. 尝试使用web3j调用合同中的某些功能。 I followed solidity guide and got the .abi and .bin of this contract - https://etherscan.io/address/0x9dda40dabd849bbb087dcbcf0c5223ec5ffa0ad7#code . 我遵循了稳定性指南并获得了该合同的.abi和.bin- https: //etherscan.io/address/0x9dda40dabd849bbb087dcbcf0c5223ec5ffa0ad7#code。 Then used web3j commandline to make the .java file wrapper, outputted to the correct directory. 然后使用web3j命令行进行.java文件包装,输出到正确的目录。

Everything works but these lines: 一切正常,但以下几行:

public static final Event FUNDSWITHDRAWN_EVENT = new Event("FundsWithdrawn",
        Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Uint256>() {}));
;

public static final Event FUNDSDEPOSITED_EVENT = new Event("FundsDeposited",
        Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Uint256>() {}));
;

public static final Event SERVERADDED_EVENT = new Event("ServerAdded",
        Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
;

public static final Event SERVERREMOVED_EVENT = new Event("ServerRemoved",
        Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
;

public static final Event GAMESTARTED_EVENT = new Event("GameStarted",
        Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<DynamicArray<Address>>() {}));
;

public static final Event GAMEENDED_EVENT = new Event("GameEnded",
        Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<Address>() {}, new TypeReference<Address>() {}, new TypeReference<Address>() {}));
;

throw error: 抛出错误:

Event() in Event cannot be applied to:
Expected Parameters:
Actual Arguments:

name:
String
"ServerAdded"  
indexedParameters:
List<TypeReference<?>>
Arrays...new TypeReference<Uint256>() {})  
nonIndexedParameters:
List<TypeReference<?>>

And these two lines: 而这两行:

    public static final Event OWNERSHIPRENOUNCED_EVENT = new Event("OwnershipRenounced",
        Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}));
;

public static final Event OWNERSHIPTRANSFERRED_EVENT = new Event("OwnershipTransferred",
        Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}, new TypeReference<Address>(true) {}));
;

Give error: TypeReference( ) in TypeReference cannot be applied to (boolean) 输入错误:TypeReference中的TypeReference()无法应用于(boolean)

I'm not the contract creator, but it does work correctly in its web3js and metamask implementation. 我不是合同的创建者,但是它确实可以在其web3js和metamask实现中正常工作。 One thing I'm thinking as these events are for serverside, do I even need to include them? 由于这些事件是针对服务器端的,我在想一件事,我是否甚至需要包含它们? (although as you can see they are referenced later) but I'm just wondering if the use of the .bin file forces you to not change things? (尽管您稍后会看到它们的引用),但我只是想知道是否使用.bin文件会强迫您不进行更改? New to this anyway so any help or direction pointing appreciated, thanks. 无论如何还是新手,感谢任何帮助或指示。

It happens to me, seems a problem with the version because the generation of the Java class has syntax errors. 在我看来,版本似乎有问题,因为Java类的生成存在语法错误。

All you can do is try to fix the issue manually: delete the true, and change a bit the code. 您所能做的就是尝试手动解决此问题:删除true,然后稍微更改代码。

public static final Event OWNERSHIPRENOUNCED_EVENT = new Event("OwnershipRenounced",
        Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}),
        Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM