web3j异步交易不能解析ExcExtTraceActoSycNC?
你需要使用executeTransaction封装包中的RemoteCall:
Function function = new Function(...); RemoteCall remoteCall = new RemoteCall(() -> { //call to executeTransaction }); TransactionReceipt receipt = remoteCall.send();
你可以通过使用web3j的代码生成工具为你的以太坊智能合约创建简单的封装包,从而使你的开发更轻松。有关如何生成代码的Web3J文档的这一部分。通过生成的类处理远程调用(以及对constant函数的本地调用)。你的客户端代码变得类似:
Web3j web3j = Web3j.build(new HttpService()); Credentials credentials = Credentials.create(<YOUR_PRIVATE_KEY>); SimpleContract contract = SimpleContract.load(<CONTRACT_ADDRESS>, web3j, credentials, BigInteger.valueOf(<GAS_PRICE>), BigInteger.valueOf(<GAS_LIMIT)); RemoteCall remoteCall = contract.setValue(BigInteger.valueOf(5)); // Call to smart contract setValue(5) TransactionReceipt receipt = remoteCall.send();
添加代码生成的示例
$ solc --version solc, the solidity compiler commandline interface Version: 0.4.19+commit.c4cbbb05.Windows.msvc
$ java -version java version "1.8.0_144" Java(TM) SE Runtime Environment (build 1.8.0_144-b01) Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
$ solc contracts/SimpleContract.sol --bin --abi --optimize -o build/
$ web3j.bat solidity generate build/SimpleContract.bin build/SimpleContract.abi -o ./src -p mypackage
_ _____ _ _
| | |____ (_) (_)
__ | | / / _ ___ \ \ /\ / / _ \ ' \ \ \ | | | / _
\ V V / __/ |) |./ / | _ | || () | _/_/ _|./ _/| |()|| _/ _/ | |/
Generating mypackage.SimpleContract ... File written to .\src
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。