Open degloff opened 4 years ago
Have the same issue;
Known issue
the wrapper generator is expecting "payable: true" rather than "stateMutability: payable" to correctly generate wrapper functions for payable function
in the meantime here is an example of a function which will take msg.value
and encode it correctly
public RemoteFunctionCall<TransactionReceipt> newGreeting(String _greeting, BigInteger weiValue) {
final Function function = new Function(
FUNC_NEWGREETING,
Arrays.<Type>asList(new org.web3j.abi.datatypes.Utf8String(_greeting)),
Collections.<TypeReference<?>>emptyList());
return executeRemoteCallTransaction(function, weiValue);
}
you should just be able to add the weiValue
as a function parameter
and then add it to the executeRemoteCallTransaction
parameters
have the same issue, see https://github.com/web3j/web3j/issues/1306
Here is the line that produces the bug https://github.com/web3j/web3j/blob/87d2446324423c0109fc856b1b0026b4e1d85e23/codegen/src/main/java/org/web3j/codegen/SolidityFunctionWrapper.java#L1466
Known issue
the wrapper generator is expecting "payable: true" rather than "stateMutability: payable" to correctly generate wrapper functions for payable function
in the meantime here is an example of a function which will take
msg.value
and encode it correctlypublic RemoteFunctionCall<TransactionReceipt> newGreeting(String _greeting, BigInteger weiValue) { final Function function = new Function( FUNC_NEWGREETING, Arrays.<Type>asList(new org.web3j.abi.datatypes.Utf8String(_greeting)), Collections.<TypeReference<?>>emptyList()); return executeRemoteCallTransaction(function, weiValue); }
you should just be able to add the
weiValue
as a function parameter and then add it to theexecuteRemoteCallTransaction
parameters
Thanks for this insight.
Any ETA on a fix for this so we don't have to manually apply the workaround?
pls any idea, when this will be merged and released please?
thanks tomas
This issue has been mentioned on Web3 Labs Community. There might be relevant details there:
impacted today, subscribing to potential solution in https://github.com/web3j/web3j/pull/1647
https://github.com/web3j/web3j/pull/1647 has been merged, this issue ccan be closed.
Java wrapper generator for smart contract does not properly handle payable functions
There is no overload generated to send Ether into the smart contract function call, even though the contract function is marked payable.
Steps To Reproduce
Consider this solidity function
Compile the contract and generate the Java wrapper. It generates
This is wrong as you have to generate an overload that passes Eth all the way down to the execution of the transaction. This is clear as the function is marked as payable.
Instead it forwards the execution of the transaction to
This is clearly wrong.
Environment