web3j icon indicating copy to clipboard operation
web3j copied to clipboard

Transaction getter must convert maxPriorityFeePerGas and maxFeePerGas too

Open b3kan opened this issue 5 years ago • 8 comments

Class:

org.web3j.protocol.core.methods.request.Transaction

Getters for provided fields should look like this:

public BigInteger getMaxPriorityFeePerGas() { return convert(maxPriorityFeePerGas); }

public BigInteger getMaxFeePerGas() { return convert(maxFeePerGas); }

b3kan avatar Aug 10 '21 10:08 b3kan

@b3kan That's right, I will update it.

yasseralaa avatar Aug 10 '21 15:08 yasseralaa

maxPriorityFeePerGas and maxFeePerGas are returned in response in Wei.

yasseralaa avatar Aug 10 '21 15:08 yasseralaa

Is this issue going to be fixed?

If these getters do not return a converted hex string, the JSON string that it forms would be wrong. For example, supposed a transaction is created with the following code:

Transaction trnx = new Transaction("[from address]", null, null, BigInteger.valueOf(69145), "[contract address]", BigInteger.ZERO,
                  "[contract data]", null, BigInteger.ZERO, BigInteger.valueOf(50000000000))

And if we send trnx using the personalSendTransaction method, the JSON that it is sent to the GETH would be something like the following:

{
	"jsonrpc": "2.0",
	"method": "personal_sendTransaction",
	"params": [
		{
			"from": "[from address]",
			"to": "[contract address]",
			"gas": "0x10e19",
			"value": "0x0",
			"data": "[contract data]",
			"maxPriorityFeePerGas": 0,
			"maxFeePerGas": 50000000000
		},
		"secretkey"
	]
}

The "maxPriorityFeePerGas" and "maxFeePerGas" nodes are supposed to be hex strings (like the "gas" node in the example above), but they are sent as numbers instead.

The call would then trigger an error with the message: "invalid argument 0: json: cannot unmarshal non-string into Go struct field TransactionArgs.maxPriorityFeePerGas of type *hexutil.Big".

avexphp avatar Aug 13 '21 15:08 avexphp

I'm having the same problem. Also, chainId has the same issue.

kobayashimaru871 avatar Aug 15 '21 18:08 kobayashimaru871

Sorry looks like a PR was created but was closed by the bot i will review it and merge it

AlexandrouR avatar Oct 19 '21 13:10 AlexandrouR

@avexphp @kobayashimaru871 @b3kan is this issue good to close?

andrii-kl avatar Jan 28 '22 13:01 andrii-kl

@avexphp @kobayashimaru871 @b3kan is this issue good to close?

The changes in the code seem good to me. But I haven't used the updated version it in my environment and might not be updating it any time soon. I am with closing this issue.

avexphp avatar Feb 18 '22 04:02 avexphp

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 16 '22 06:04 stale[bot]