web3j-maven-plugin icon indicating copy to clipboard operation
web3j-maven-plugin copied to clipboard

Generated code cannot deploy EIP-1559 compliant contract

Open ocarlsen opened this issue 4 years ago • 0 comments

After using the plugin to generate Java wrapper from DocumentRegistry.sol file, I try to deploy contract like this:

        public static void main(final String[] args) throws Exception {
            final String url = "https://rpc.goerli.mudit.blog/";
            final Web3j web3 = Web3j.build(new HttpService(url));

            final Credentials creds = Credentials.create("private-key");

            final String fromAddress = creds.getAddress();
            System.out.println("fromAddress = " + fromAddress);

            // Error processing transaction request: only replay-protected (EIP-155) transactions allowed over RPC
            final DocumentRegistry registryContract = DocumentRegistry.deploy(web3, creds, new org.web3j.tx.gas.DefaultGasProvider()).send();

            final String contractAddress = registryContract.getContractAddress();
            System.out.println("contractAddress = " + contractAddress);
        }

However, I get this exception:

Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: Error processing transaction request: only replay-protected (EIP-155) transactions allowed over RPC
	at org.web3j.tx.Contract.deploy(Contract.java:460)
	at org.web3j.tx.Contract.lambda$deployRemoteCall$7(Contract.java:608)
	at org.web3j.protocol.core.RemoteCall.send(RemoteCall.java:42)
	at io.kauri.tutorials.java_ethereum.DeployContract$DocumentRegistryContract.main(DeployContract.java:25)
Caused by: java.lang.RuntimeException: Error processing transaction request: only replay-protected (EIP-155) transactions allowed over RPC
	at org.web3j.tx.TransactionManager.processResponse(TransactionManager.java:176)
	at org.web3j.tx.TransactionManager.executeTransaction(TransactionManager.java:81)
	at org.web3j.tx.ManagedTransaction.send(ManagedTransaction.java:128)
	at org.web3j.tx.Contract.executeTransaction(Contract.java:367)
	at org.web3j.tx.Contract.create(Contract.java:422)
	at org.web3j.tx.Contract.deploy(Contract.java:456)

Plugin configuration is below.

            <plugin>
                <groupId>org.web3j</groupId>
                <artifactId>web3j-maven-plugin</artifactId>
                <version>4.8.2</version>
                <executions>
                    <execution>
                        <id>generate-sources-web3j</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generate-sources</goal>
                        </goals>
                        <configuration>
                            <packageName>me.gjeanmart.tutorials.javaethereum.contracts.generated</packageName>
                            <sourceDestination>${basedir}/target/generated-sources/contracts</sourceDestination>
                            <soliditySourceFiles>
                                <directory>${basedir}/src/main/resources</directory>
                                <includes>
                                    <include>**/*.sol</include>
                                </includes>
                            </soliditySourceFiles>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Source DocumentRegistry.sol is attached: DocumentRegistry.sol

ocarlsen avatar Sep 22 '21 15:09 ocarlsen