Skip to content

Fix missing weiValue in transaction when estimating gas for payable function#2206

Merged
gtebrean merged 3 commits intoLFDT-web3j:mainfrom
liulinhui:main
Nov 12, 2025
Merged

Fix missing weiValue in transaction when estimating gas for payable function#2206
gtebrean merged 3 commits intoLFDT-web3j:mainfrom
liulinhui:main

Conversation

@liulinhui
Copy link
Copy Markdown
Contributor

What does this PR do?

to fix #1268

Fix an issue where the weiValue is not set in the constructed transaction during gas estimation for a payable function, which leads to failure.

Where should the reviewer start?

org.web3j.tx.Contract

Why is it needed?

When estimating gas for a payable function, the transaction must include the correct weiValue to reflect the actual call conditions. Without setting the weiValue, the gas estimation does not accurately represent a real invocation, and in many contracts, this leads to a revert or failure during the estimation phase.

This fix ensures the weiValue is properly included in the transaction used for gas estimation, which allows the estimation to succeed and reflect real execution costs.

Checklist

  • I've read the contribution guidelines.
  • I've added tests (if applicable).
  • I've added a changelog entry if necessary.

…ble function

Signed-off-by: liulinhui <1249055292@qq.com>
Signed-off-by: liulinhui <1249055292@qq.com>
Signed-off-by: liulinhui <1249055292@qq.com>
@FangshuoCao
Copy link
Copy Markdown
Contributor

I’ve tested this fix on Sepolia using a simple payable contract (deposit() with require(msg.value > 0)) and confirmed that gas estimation now correctly includes the weiValue. This should be good to go.

@gtebrean gtebrean merged commit 6791829 into LFDT-web3j:main Nov 12, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Java wrapper generator does not properly handle payable functions

3 participants