I'm attempting to transfer an erc20 token, but keep running into insufficiant funds for gas * price + value, regardles of how much eth I have, I also have an estimate function which returns a value thats several times lower than what I have in eth.
I'm using Infura.
My ETH balance is:
79475000000000000 (0,079475)
Here's my estimate output:
2020-08-31 14:49:26,036 INFO [EthResource] (vert.x-worker-thread-1) ########## Entering doTokenEstimateTransactionFee...
2020-08-31 14:49:26,513 INFO [Web3jService] (vert.x-worker-thread-1) >>>>>>>>>> (Token tx) DefaultGasProvider.GAS_LIMIT = 4300000
2020-08-31 14:49:26,673 INFO [Web3jService] (vert.x-worker-thread-1) >>>>>>>>>> (Token tx) ethEstimateGas.amountUsed = 21584
2020-08-31 14:49:26,674 INFO [Web3jService] (vert.x-worker-thread-1) >>>>>>>>>> (Token tx) ethGasPrice.gasPrice = 217000000000
2020-08-31 14:49:26,674 INFO [Web3jService] (vert.x-worker-thread-1) >>>>>>>>>> (Token tx) estimated tx fee = 4683728000000000
2020-08-31 14:49:26,674 INFO [EthResource] (vert.x-worker-thread-1) ########## (success) Leaving doTokenEstimateTransactionFee...
So the fee should be 0,004683728, which is less than my balance.
Here's my code:
@Synchronized
fun TokenTransferFrom(TokenTransferFromDto: TokenTransferFromDto): ResultDto {
return try {
val sourceCredentials: Credentials = Util.generateCredentialsBip32(TokenTransferFromDto.sourceMnemonic)
return if (TokenTransferFromDto.sourcePrivateKey == sourceCredentials.ecKeyPair.privateKey.toString(16)) {
val fastRawTransactionManager = FastRawTransactionManager(web3j, sourceCredentials, NoOpProcessor(web3j))
// Load contract by source
val TokenSource = load(infuraTokenContractAddress, web3j, fastRawTransactionManager, DefaultGasProvider())
val transactionReceipt = TokenSource.transfer(TokenTransferFromDto.destination, TokenTransferFromDto.amount).send()
if (!transactionReceipt.isStatusOK) {
return wrapError("transactionReceipt.isStatusOK false", transactionReceipt.status)
}
logger.info(">>>>>>>>>> TokenTransferFrom txHash = ${transactionReceipt.transactionHash}")
ResultDto("success", null, "", transactionReceipt.transactionHash, null, null, null)
} else {
wrapError("", "Invalid mnemonic or private key")
}
} catch (e: Exception) {
logger.error(">>>>>>>>>> EXCEPTION: ${e.message}")
wrapError("", e.message.toString())
}
}
Can someone tell me what I have to change to be able to specify my own GAS_LIMIT as I'm stumped?
Here's the error that I endlessly keep encountering:
2020-08-31 14:54:34,787 ERROR [Web3jService] (vert.x-worker-thread-4) >>>>>>>>>> EXCEPTION: Error processing transaction request: insufficient funds for gas * price + value
I'm completely new to kotlin, java, so sorry if I'm dumb. Thanks.