I'm trying to develop a Dapp but I'm stuck right now, due to this error that I'm getting while sending value from my frontend to smart contract.

So, basically I want to update the UI once this transaction is successful.

This is my smart contract. The function makeAd() will update the owner and amount if the value sent by the sender is greater than the last amount.

contract AdAuction {
address currentOwner;
uint currentAmount = 0 wei;

event advertisement(address owner, uint amount);

function makeAd() public payable {
    require(msg.value > currentAmount, "Pay more to make changes");
    currentOwner = msg.sender;
    currentAmount = msg.value;
    emit advertisement(msg.sender, msg.value);

function getOwner() external view returns (address) {
    return currentOwner;

function getAmount() external view returns (uint amount) {
    return currentAmount;


This is the function from my react frontend, in which I call the makeAd() from smart contract. And I take the amount value from an input field (of type=number), which is referenced as "amountRef".

const handleClick = (event) => {
            let config = {
                value: web3.utils.toWei(amountRef.current.value, "ether")
            adAuction.methods.makeAd().send({ from: userAccount[0], config })
            .then((result) => {

But instead I'm getting this error:

enter image description here

Please help me solve this. I tried but wasn't able to solve it, and now I'm stuck. I've no idea why I'm getting this error.

1 Answer 1


I would recommend reviewing error handling in solidity. I am not 100% on your browser console error log pic, but one thing that does stand out in your question is:

"basically I want to update the UI once this transaction is successful."

Also attaching a link that best describes error handling in Solidity

The concept of require is require( (condition),'error occured'). In simple terms, "require" enforce conditions to run function. This is a good practice highly recommended. Note: the remainder gas will be used up by the network. There is no work-around for this unfortunately yet. For eg: Assuming there is addFunds() function that can be only called by Owner, you can set require inside the function that will suffice the condition. With that being said, on your react front-end you can check if an error was returned from a solidity contract call. Make sure when you call makeAd() the user connects metamask Wallet first (please please make sure your are on rinkeby testnet not on Mainnet) If yes, then alert the user else return a successful message and update the state if needed.

Hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.