I am transferring funds using web3j. However, I was getting transactionHash as null. I checked various posts and found that this issue exist when gas price or gas is bad. I increased both the values, and it started working. However, the same code didn't work on other machine. So, again i changed the gas price and value and it worked. But then for some other data, it didnt work. So, its random.
My conerns: 1. I can't keep changing the values dynamically, since I don't know how much gas is required at run time. 2. Most of all, Gas price and limit that i have set are already too high (please check my code below). Even the account balance will never be that much. In reality, I can't set that much value.
Please help me here.
static BigInteger GAS_PRICE = BigInteger.valueOf(new Long(18000000000L));
static BigInteger GAS_LIMIT_ETHER_TX = BigInteger.valueOf(300000);
RawTransactionManager rawTransactionManager = new RawTransactionManager(web3j ,credentials,100,1000 * 15);
EthSendTransaction send = rawTransactionManager.sendTransaction(GAS_PRICE, GAS_LIMIT_ETHER_TX, "toAddress", "<some data to save>", BigInteger.valueOf(1));
Even the amount to transfer is not big, and neither is my data to save. Is my gasLimit set in genesis too high, which is why it is expecting this much gas?
{
"config": {
"chainId": 1994,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0
},
"difficulty": "400",
"gasLimit": "2000000",
"alloc": {
"<root address>":{
"balance":"1000000000000000000000000"
}}}