In the learning journey of blockchain ethereum solidity smart contract, many of us have faced various problems and invested some time in getting fruitful solutions. I think finding the solution only isn’t very satisfactory instead of reaching the ‘WHY’ behind each small problem. What do you think?
Here, I am sharing minor but mostly faced errors while working as a beginner with the solidity smart contract.
Problem:
While deploying the smart contract on the Remix, I was facing one error in contract deployment.
Error:
The transaction has been reverted to the initial state. The called function should be payable if you send value and the value you send should be less than your current balance.

Approach:
Here, I am describing the approaches I've taken as below. The approach was,
- Checking my wallet for ether balance. Because the error was about the less balance, I have checked the ether balance in my metamask wallet. Then I reached the next query.
- So from the first approach, the second query raises in my mind like “How my meta mask wallet is connected to the remix environment” in terms of balance. Because I have not made any connection between my metamask wallet and Remix editor.
- As I did the checking in the second approach, I was not getting the answer of “From where the contract is taking balance which is insufficient”.
Solution:
I was literally stuck for some time in this issue. With a peaceful mind, I have started doing productive debugging. Below is what I have found.
While checking the input fields I am passing while deployment, I have found that I was passing the “value: 1 ether” while deployment.

But in my solidity smart contract, I was declaring a constructor function as Public.
Looking for MEAN/MERN stack developer? Contact us now.WHY:
So the reason behind this problem was, if you’re doing any kind of transaction in the smart contract functions, you need to declare that function as ‘Payable’.
Here I was passing 10 ether while deploying my contract and as the first method of a class, constructor was called. But by passing some ethers in deployment process initialization, it went to the constructor and the constructor was not having the ‘Payable’ method. So the process has been reverted and could not be completed due to this reason.
I have added the ‘Payable’ keyword in the constructor declaration and my contract has been deployed successfully! YeeY…

Is this explanation helpful to you? Do you’ve anything to add on? Please feel free to comment. Thanks.

Let’s discuss about your next AI, Cloud or Digital Transformation.
AI-Skilled & Agile
Transparent, Trustworthy &
Vetted teamNot tech, but business &
customer first approach


