无法使用web3j(Java客户端)将智能合约部署到私有链上,错误提示信息是超时。
我用web3j与我在Azure中创建的私有链进行交互。我使用Remix和Metamask创建了以太坊智能合约,并且能够从Java中查看该智能合约。
但是,我无法从Java部署或创建合同。我遵循了web3j的命令但是抛出了这个:
1.错误提示:Transaction receipt was not generated after 600 seconds for transaction
2.报错原因是:org.web3j.protocol.exceptions.TransactionTimeoutException
我的代码如下:
ContractRunner.java
public static void main(String args[]) throws InterruptedException, ExecutionException, IOException, CipherException, TransactionTimeoutException {
Web3j web3 = Web3j.build(new HttpService("http://xxxxxxxxx.westus.cloudapp.azure.com:8545/")); // defaults to http://localhost:8545/
Web3ClientVersion web3ClientVersion = web3.web3ClientVersion().sendAsync().get();
String clientVersion = web3ClientVersion.getWeb3ClientVersion();
System.out.println(clientVersion);
Credentials credentials = WalletUtils.loadCredentials("MyPassword", "C:\\Users\\adheep_m\\AppData\\Roaming\\Ethereum\\keystore\\UTC--2017-07-07T13-52-18.006069200Z--3b0d3fa08f0e0b3da8fe1f8ac0e05861bfdada25");
System.out.println(credentials.getAddress());
Token contract = Token.deploy(web3,credentials,BigInteger.valueOf(3000000),BigInteger.valueOf(3000000),BigInteger.valueOf(0)).get