Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile solidity error #18

Open
kworldljd opened this issue Aug 6, 2019 · 11 comments
Open

compile solidity error #18

kworldljd opened this issue Aug 6, 2019 · 11 comments
Assignees
Labels

Comments

@kworldljd
Copy link

download solc and put in the root directory of project .
then command run grandlew.bat build then show error:
Error: Source file requires different compiler version (current compiler is 0.5.10+commit.5a6ea5b1.Windows.msvc - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.4.25;

change the pragma solidity >0.4.25 then get more errors.
please update solidity file.

@xaviarias
Copy link

Hi, the contract Greeter provided in this project has to be compiled with Solidity version 0.4.25.

If you install solc in version 5 the contract won't compile. We will update the samples to use the last version of the web3j plugin so you don't need to install solc and use the bundled one.

If you want to do it yourself you can change version 4.1.2 to 4.1.3 in the plugins section of the Gradle build file:

plugins {
    id 'java'
    id 'org.web3j' version '4.1.3'
}

@kworldljd
Copy link
Author

Hi, the contract Greeter provided in this project has to be compiled with Solidity version 0.4.25.

If you install solc in version 5 the contract won't compile. We will update the samples to use the last version of the web3j plugin so you don't need to install solc and use the bundled one.

If you want to do it yourself you can change version 4.1.2 to 4.1.3 in the plugins section of the Gradle build file:

plugins {
    id 'java'
    id 'org.web3j' version '4.1.3'
}

Thank you for your answer!
Before you reply, I modify the greeter.sol file and make it can be compiled by solc 5.
then make java wrapper greeter.java follow the document by hand.
I fix the Application.java to connect testnet Rinkeby, and get the wallet address balance. It looks well according to the log info ,But when call Transfer.sendfunds ,it's timeout. there are not more details .why can't send? what is the problem? how to check and fix. thank you very much !
------------------sendfunds:
TransactionReceipt transferReceipt = Transfer.sendFunds(
web3j, credentials,
"0x76BE1022Afa6375E6D30BAD7a6Eae4ACC4D197B6", // you can put any address here
BigDecimal.ONE, Convert.Unit.WEI) // 1 wei = 10^-18 Ether
.send();

----------------------log
23:34:22.743 [main] INFO org.web3j.sample.Application - Connected to Ethereum client version: Geth/v1.8.25-omnibus-c41559d0/linux-amd64/go1.11.1
23:34:25.230 [main] INFO org.web3j.sample.Application - Credentials loaded
23:34:25.499 [main] INFO org.web3j.sample.Application - address 0xaf5120e13dfe8ec8a5f42fd279d499786229b2e1 balance : 1463371227999999991
23:34:25.503 [main] INFO org.web3j.sample.Application - Sending 1 Wei (0.000000000000000001 Ether)

---------------errors:
Exception in thread "main" org.web3j.protocol.exceptions.TransactionException: Transaction receipt was not generated after 600 seconds for transaction: 0x8bd1520cdc9f73c9a24a43292b8469f0fd0bde7028ec6609260bf2ca2342c559
at org.web3j.tx.response.PollingTransactionReceiptProcessor.getTransactionReceipt(PollingTransactionReceiptProcessor.java:51)
at org.web3j.tx.response.PollingTransactionReceiptProcessor.waitForTransactionReceipt(PollingTransactionReceiptProcessor.java:29)
at org.web3j.tx.TransactionManager.processResponse(TransactionManager.java:72)
at org.web3j.tx.TransactionManager.executeTransaction(TransactionManager.java:51)
at org.web3j.tx.ManagedTransaction.send(ManagedTransaction.java:87)
at org.web3j.tx.Transfer.send(Transfer.java:65)
at org.web3j.tx.Transfer.send(Transfer.java:49)
at org.web3j.tx.Transfer.lambda$sendFunds$0(Transfer.java:76)
at org.web3j.protocol.core.RemoteCall.send(RemoteCall.java:30)
at org.web3j.sample.Application.run(Application.java:82)
at org.web3j.sample.Application.main(Application.java:54)

@kworldljd
Copy link
Author

@xaviarias @AlexandrouR Maybe,I know why program run timeout。
The reason is that get gasprice from Rinkeby is 0x3b9aca00(1000000000). In the metaMask, I use this value ,it tips error. Then use 4 or 10, it can send funds.

The problem is in the transfer.java ;
private TransactionReceipt send(String toAddress, BigDecimal value, Convert.Unit unit)
throws IOException, InterruptedException, TransactionException {

    BigInteger gasPrice = requestCurrentGasPrice();  //debug return 0x3b9aca00
    return send(toAddress, value, unit, gasPrice, GAS_LIMIT);
}

It's only in the debug model show ,and the file(transfer.java) is readonly ,I can't modify and test .

May it's the bug in the testnet Rinkeby, following is the debug info :

=====================log debug model
22:28:52.143 [main] DEBUG org.web3j.protocol.http.HttpService - {"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":2}
22:28:52.145 [main] DEBUG org.web3j.protocol.http.HttpService - --> END POST (60-byte body)
22:28:52.503 [main] DEBUG org.web3j.protocol.http.HttpService - <-- 200 https://rinkeby.infura.io/v3/2e1e7f63bc1e483da325fca710770dbb (353ms)
22:28:52.506 [main] DEBUG org.web3j.protocol.http.HttpService - date: Wed, 07 Aug 2019 14:28:52 GMT
22:28:52.509 [main] DEBUG org.web3j.protocol.http.HttpService - content-type: application/json
22:28:52.511 [main] DEBUG org.web3j.protocol.http.HttpService - content-length: 46
22:28:52.513 [main] DEBUG org.web3j.protocol.http.HttpService - vary: Origin
22:28:53.802 [main] DEBUG org.web3j.protocol.http.HttpService -
22:28:53.804 [main] DEBUG org.web3j.protocol.http.HttpService - {"jsonrpc":"2.0","id":2,"result":"0x3b9aca00"}
22:28:53.805 [main] DEBUG org.web3j.protocol.http.HttpService - <-- END HTTP (46-byte body)
22:37

This is one transaction by progam sended:
https://rinkeby.etherscan.io/tx/0x395f06af6a55cc21b2c66dca2c8477e22cfdf356b911d7b2e1327a6886f3b4ff

@AlexandrouR
Copy link
Contributor

@kworldljd The best way to see if this is an issue with the Rinkeby network is to use ganache can you please to do that and tell me if the transaction passes ?

@kworldljd
Copy link
Author

@kworldljd The best way to see if this is an issue with the Rinkeby network is to use ganache can you please to do that and tell me if the transaction passes ?

ok, I will use ganache to test tomorrow.

Today, I read the Transfer.java and retry to use another sendFunds function that can set gasprice and gaslimit. the following is the test code.
TransactionReceipt transferReceipt = new Transfer(web3j, new RawTransactionManager(web3j,credentials)). sendFunds("0x76BE1022Afa6375E6D30BAD7a6Eae4ACC4D197B6",BigDecimal.ONE,Convert.Unit.WEI,BigInteger.TEN,Transfer.GAS_LIMIT).send();

I set gasprice is 10, but it does not work again, program is still timeout. the transaction is pending(https://rinkeby.etherscan.io/tx/0x2b9d99db4e1c6039b629267d873dec79defe774156fc6b78b9a52de99f3b4f2c)

I use the metamask the same value, the transaction is ok. the Rinkeby is ok, maybe is the problem of infura.io

There are no more details to locate where is the bug . It is horrible!

@kworldljd
Copy link
Author

@kworldljd The best way to see if this is an issue with the Rinkeby network is to use ganache can you please to do that and tell me if the transaction passes ?

Today, I use ganache replace Rinkeby, it looks everything work well . But retry in Rinkeby, sendFunds doesn't work again. Transaction is always pending. and program is timeout .
https://rinkeby.etherscan.io/tx/0x95fd2c2793774e86c8b5ad833757f0f2f5130c652a82522c167d806d387f8dfe

image

@kworldljd
Copy link
Author

@AlexandrouR
Copy link
Contributor

@kworldljd I replicated your code and also send a few transactions using a few alternatives. The result was the same on Ganache and Metamask was able to send the transaction on Rinkeby. I will test on geth --rinkeby.

@kworldljd
Copy link
Author

I use infura to connect the testnet Rinkeby.
on Ganache, it works well. when on Rinkeby connected by infura, it run timeout.

@kworldljd
Copy link
Author

@AlexandrouR @xaviarias Refresh the question。It's the problem of my wallet file.
Today, I use the web3j command line tools to send funds with my wallet on Rinkeby, it still faulted.
then use the command line tools to create a new wallet file to send funds to other address . It worked
.
I use this new wallet file path to replace the program. everything is working well .

Why? What is the problem of the prior wallet file created by the same web3j command line tools , according to the offical document ?
There were no any tips on the debug model. The terminate was only showing that getting the transaction's result was null and then timeout.

@kworldljd
Copy link
Author

kworldljd commented Aug 15, 2019

the main question is "There were no any tips on the debug model. The terminate was only showing that getting the transaction's result was null and then timeout." with on Rinkeby and it works well on ganache. it takes my care, and then I can't fix what's the problem

The following are the wallet files. The new wallet password:111111, the prior wallet password:web3j.io

new wallet fileUTC--2019-08-15T15-21-33.293059500Z--e6724addbd9a1c0f23673e5b583780e0e51e4204.zip

the prior wallet file :
the prior wallet fileUTC--2019-08-04T01-58-07.315000000Z--af5120e13dfe8ec8a5f42fd279d499786229b2e1.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants