Forum

Frontend bug when using "Write Contract" to send value (ETH) in payable functions

Hi team, there is a frontend bug when using “Write Contract” interface to send value (ETH) for payable functions.

Please see this test contract that highlights this problem:
https://polygon-explorer-mumbai.chainstacklabs.com/address/0x0BFE0fdf714ef900d0F3F63194E84A99a0Caad35/write-contract

Test contract code:

contract Test {

uint public var1;
uint public var2;

constructor () public {}

fallback() external payable {}
receive() external payable {}

function updateVarAndSendETH(uint _var1, uint _var2) external payable {
    var1 = _var1;
    var2 = _var2;
}

}

There is no issue when you use fallback function to send 0.1 MATIC to contract.

However if you use updateVarAndSendETH function to update var1 & var2 & send 0.1 MATIC, the frontend shows an error message “Unauthorized: Given input “16345785d8a0000” is not a number.”

I believe the error is because the javascript function for converting value(ETH) to hexadecimal forgot to add a “0x” in front of “16345785d8a0000”, since 0x16345785d8a0000 is equivalent to 0.1 ETH in hexadecimals.

Would appreciate your help to resolve this frontend problem. Thank you.

1 Like

The same contract does not have this issue when published on etherscan or bscscan.

Would really appreciate if you can fix this.

1 Like