Web3j: why not-enough gas?

Created on 5 Apr 2018  路  9Comments  路  Source: web3j/web3j


TransactionReceipt transactionReceipt = null;

try {

Credentials credentials = WalletUtils.loadCredentials(ETH_COINBASE_PASSWORD, PATH_TO_WALLET);
TESTToken tokenContract = TESTToken.load(TESTTOKEN_CONTRACT_ADDRESS, web3j, credentials, Contract.GAS_PRICE, Contract.GAS_LIMIT);
transactionReceipt = tokenContract.transfer(toAddress, amount).sendAsync().get();

} catch (Exception e) {
e.printStackTrace();
}

return transactionReceipt;

ok! i trasfered TESTToken to other address. but when call sendAsync().get() below error

java.util.concurrent.ExecutionException: org.web3j.protocol.exceptions.TransactionException: Transaction has failed with status: null. Gas used: 37005. (not-enough gas?)

why not-enough gas?

BUT TESTToken was sent to other address.

how can i set gas for contract? T^T

Most helpful comment

Maybe this is because of the solcjs compiler. I have encountered the same problem and tried to redeploy many times. Sometimes it can deploy successfully but most of the time I got the above exception. Thanks to this, I start to compare the bytecode generated by web3j to the bytecode generated by remix. It was different! After replacing the bytecode with remix bytecode, problem solved! At least my problem solved.

All 9 comments

Hi @basquiat78
web3j expects a transaction result to have status equal to 0x1, but for some reason, the status is equal to null. What client and what network are you using?

Hi! @mushketyk

network is private network and clientVersion: "Geth/v1.8.2-stable-b8b9f7f4/windows-amd64/go1.9.2"

@basquiat78 @conor10 I've created a PR that should fix the issue: https://github.com/web3j/web3j/pull/479

and one more question.

Is this issue related to ens?

in my case there was an error in
private static final String BINARY = "0x0....."
strangely there was an "\ before "0x0.." after using web3j to generate the contract warpper
so removing this parasite bring thing back to normal

I receive the same error:
org.web3j.protocol.exceptions.TransactionException: Transaction has failed with status: 0x0. Gas used: 35513. (not-enough gas?)

Please advise how to fix it.

Maybe this is because of the solcjs compiler. I have encountered the same problem and tried to redeploy many times. Sometimes it can deploy successfully but most of the time I got the above exception. Thanks to this, I start to compare the bytecode generated by web3j to the bytecode generated by remix. It was different! After replacing the bytecode with remix bytecode, problem solved! At least my problem solved.

I receive the same error:

Transaction has failed with status: 0xc. Gas used: 1586150. (not-enough gas?)
when i remove some function, it can work.

don't know how to fix it?

I am using gradle plugins solc, web3j-cmdline-tools to compile solidity, and geneated abi, bin files, and which also generates the java wrapper class for the smartcontract.

My binary got generated and inserted into the wrapper class normally without any mistakes.

private static final String BINARY = "608060405234801561001057600080fd5b506.......6564a265627a7a723158204aff14564d07b5975af7c443a1c8a182f28eaf197d11339a908128daee1c784a64736f6c634300050b0032";

Even I am facing the same issue:

org.web3j.protocol.exceptions.TransactionException: Transaction has failed with status: 0x0. Gas used: 0. (not-enough gas?)
at org.web3j.tx.Contract.executeTransaction(Contract.java:297)
at org.web3j.tx.Contract.executeTransaction(Contract.java:275)
at org.web3j.tx.Contract.executeTransaction(Contract.java:269)
at org.web3j.tx.Contract.lambda$executeRemoteCallTransaction$3(Contract.java:321)
at org.web3j.protocol.core.RemoteCall.send(RemoteCall.java:30)
at com.mphasis.quorum.payments.PaymentSubmissionWrapper.main(PaymentSubmissionWrapper.java:113)

I have tried replacing the BINARY/bytecode of solc compiler with the remix generated one. But still I am getting same error.

I have removed the "new DefaultGasProvider() and used StaticGasProvider() with so many custom gas values. But still problem is not resolved.
ScreeningContract.deploy(quorumNode1, transactionManagerAccountNode1, new StaticGasProvider(BigInteger.valueOf(4700000), BigInteger.valueOf(10000000))).send();

But the great development i found in this issue is that the transaction is getting inserted into quorum blockchain. I can see the new block hash, transaction hash on the quorum network. But why I am getting this org.web3j.protocol.exceptions.TransactionException is I am not able to understand and resolve. Is it the issue of Web3J api/jar..?

Can anybody help me solving this problem.

Was this page helpful?
0 / 5 - 0 ratings