web3j / sample-project-gradle

Sample web3j project using Gradle
268 stars 150 forks source link

Sample contract is not deployed. Not enough gas #14

Open StanislavMakarov opened 5 years ago

StanislavMakarov commented 5 years ago

Transfer transaction works OK, but deploy fails. What's wrong? Source code: ContractGasProvider contractGasProvider = new DefaultGasProvider(); try {

        contract = Greeter.deploy(
                web3j, credentials,
                contractGasProvider,
                "Hello!"
        ).send();
        contractAddress  = contract.getContractAddress();
        System.out.printf("Contract Address : " + contract.getContractAddress());
    } catch(Exception e){
        e.printStackTrace();
    }

08:34:34.908 [main] INFO org.web3j.sample.Application - Deploying smart contract org.web3j.protocol.exceptions.TransactionException: Transaction has failed with status: 0x0. Gas used: 4300000. (not-enough gas?) at org.web3j.tx.Contract.executeTransaction(Contract.java:290) at org.web3j.tx.Contract.create(Contract.java:326) at org.web3j.tx.Contract.deploy(Contract.java:355) at org.web3j.tx.Contract.lambda$deployRemoteCall$7(Contract.java:449) at org.web3j.protocol.core.RemoteCall.send(RemoteCall.java:30) at org.web3j.sample.Application.run(Application.java:124) at org.web3j.sample.Application.main(Application.java:67) Exception in thread "main" java.lang.NullPointerException at org.web3j.sample.Application.run(Application.java:144) at org.web3j.sample.Application.main(Application.java:67) Disconnected from the target VM, address: '127.0.0.1:62773', transport: 'socket'

JoaquimLey commented 5 years ago

This might look like a studio and obvious question(s) but...

ref: #4

iikirilov commented 5 years ago

@JoaquimLey this is not the issue. This error means that the contract deployment has gone over the gas limit.

@StanislavMakarov have you modified the contract constructor method? What network are you connecting to?

JoaquimLey commented 5 years ago

@iikirilov Thanks for correcting me 🙏 That's the Tx I was referring to, the actual deployment but I see how confusing might wording might've been :).