Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

348
Views
Error encountered during contract execution [stack underflow (0 <=> 2)]

I'm developing an ERC721 contract. Whenever i call my mint function, i get this error :

Error encountered during contract execution [stack underflow (0 <=> 2)]

My function contains nothing but a simple require and return statement.

Any Help would be very much appriciated

I then downgraded to Sol 0.6.6 But i keep getting the same issue. Even meta mask shows this message when im about to confirm the transaction :

enter image description here

This is my Mint function :

function Mint() notBroke external payable returns (uint256) {  

    require(msg.value >= 0.05 ether, 'You didnt pay enough Eth Buddy :/'); 

    return 1;
}

This is My notBroke Modifier :

   modifier notBroke() {
    require(address(this).balance > 0 ether,"You  Broke");
    _;
}

And this is how I am committing the transaction from the Front end (using meta mask) :

        const transactionParameters = {
              to: Contract.address, 
              from: props.account, // must match user's active address.
              value: parseInt(Web3.utils.toWei("0.05", 'ether')).toString(16), 
              data: web3.eth.abi.encodeFunctionCall(    
                {
                    "inputs": [],
                    "name": "Mint",
                    "outputs": [
                      {
                        "internalType": "uint256",
                        "name": "",
                        "type": "uint256"
                      }
                    ],
                    "stateMutability": "payable",
                    "type": "function"
                  },[]
            ),
              chainId: `0x${parseInt(props.network)}`, // Used to prevent transaction reuse across blockchains. Auto-filled by MetaMask.
            };


            await window.ethereum.request({
              method: 'eth_sendTransaction',
              params: [transactionParameters],
            }).then( (result) => {

                 resolve(result) 

            }).catch((error)=> resolve(error))

And this is whats shown on Etherscan :

enter image description here

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Here you have added modifier Which means your contract should have balance greater then 0, so at first time your contract will have 0 ether so it will revert transaction, please try to check balance of your contract and I think so you should check balance user who want to mint token

about 4 years ago · Juan Pablo Isaza Report

0

The modifier throws an exception (effectively reverting the transaction) with message "You Broke" if the contract address (not the sender address) has 0 balance.


If you want to update the modifier to revert only if the sender address has 0 balance, you need to use msg.sender instead of address(this):

require(msg.sender.balance > 0 ether,"You  Broke");
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!