web3j icon indicating copy to clipboard operation
web3j copied to clipboard

FastRawTransactionManager is not able to deploy smartcontract

Open flefevre opened this issue 8 years ago • 5 comments

When creating a FastRawTransactionManager with the web3j SimpleStorage.sol, I am not able to deploy it.

Small github repository to display the error

git clone https://github.com/flefevre/web3jmultipletx.git
cd web3jmultipletx
mvn clean install -f web3jmultipletxsmartcontract/pom.xml 

And run the web3jmultipletxsmartcontract/MultipleCreationFastTransactionManager.java

Any idea?

Error:

1948 [main] INFO org.github.web3j.web3jmultipletxsmartcontract.MultipleCreationFastTransactionManager - 1535464950175	Deploy first time with send: 
fastRawTxMgr.getCurrentNonce()=-1
java.lang.RuntimeException: java.lang.NoSuchMethodException: org.github.web3j.web3jmultipletxsmartcontract.SimpleStorage.<init>(java.lang.String, org.web3j.protocol.Web3j, org.web3j.tx.TransactionManager, org.web3j.tx.gas.ContractGasProvider)
	at org.web3j.tx.Contract.deploy(Contract.java:375)
	at org.web3j.tx.Contract.lambda$deployRemoteCall$6(Contract.java:404)
	at org.web3j.protocol.core.RemoteCall.send(RemoteCall.java:30)
	at org.github.web3j.web3jmultipletxsmartcontract.MultipleCreationFastTransactionManager.main(MultipleCreationFastTransactionManager.java:61)
Caused by: java.lang.NoSuchMethodException: org.github.web3j.web3jmultipletxsmartcontract.SimpleStorage.<init>(java.lang.String, org.web3j.protocol.Web3j, org.web3j.tx.TransactionManager, org.web3j.tx.gas.ContractGasProvider)
	at java.lang.Class.getConstructor0(Class.java:3082)
	at java.lang.Class.getDeclaredConstructor(Class.java:2178)
	at org.web3j.tx.Contract.deploy(Contract.java:362)
	... 3 more
Contract is null

flefevre avatar Aug 29 '18 08:08 flefevre

A new analysis of the problem shows thazt the problem is linked to web3j-maven-plugin See: https://github.com/web3j/web3j-maven-plugin/issues/34

flefevre avatar Sep 11 '18 09:09 flefevre

In the web3j-maven-plugin, Heinz M. analysis shows it is not in web3j-maven-plugin since it is a helper plugin. So the error has to be address here in web3j generator. I will copy/paste my small analysis here:

Initially I was thinking the error comes from FastRawTransactionManager, in fact after a deeper analysis it is due to the fact the generated code from web3j-Maven-plugin is not compliant with latest changes in web3j plugin.

protected SimpleStorage(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit);
    }

    protected SimpleStorage(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit);
    }

Badly default constructor with super are deprecated in Contract class

By adding manually the following one, I was able to solve the error

protected SimpleStorage(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
        super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
    }

So I would like to propose a PR where the generator is upgraded with a new constructor with transactionManager, contractGasProvider parameters

flefevre avatar Sep 13 '18 06:09 flefevre

Hi, you can follow similar way as in this pull request https://github.com/web3j/web3j/pull/657

MykolaMarkov avatar Sep 13 '18 07:09 MykolaMarkov

Hello, I have made of PR based on the one you show me Could you have a look to it? Do not hesitate to ask me modifications in order to improve the work https://github.com/web3j/web3j/pull/709 Thanks

flefevre avatar Sep 14 '18 08:09 flefevre

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 19 '19 06:08 stale[bot]