# Calling function with one parameter in Solidity

I am trying to call a function with one parameter I have used these methods all didn't work: //z=addmul(total); //this.addmul(total); This is the function created:

``````function addmul(uint256 a, uint256 b) internal pure returns (uint256 c  ) {

require(c >= a && c>=b, "SafeMath: overflow encountered");

return c;

}
``````

This is how it was called, given unexpected result:

``````//multiplication operation
function multiplication(uint256 x, uint y) public  {
total=x+y;
total.addmult;  // this one runs, but it does not give desired result
}
``````

I want the addmull function to effect the computed value of total variable. The main essence of the function is to protect an overflow when x and y are added or multiplied together.

• Solidity is a pretty challenging language to start learning programming, I'd suggest to first try learning javascript which solidity is close in syntaxis.
– Ismael
Jul 7, 2019 at 17:45
• Thank you so much. Jul 7, 2019 at 21:40

1. it does not use the second argument (b)
2. it requires c to be bigger than a, but c being a return value is initialized as 0 at function start, so your code makes this function systematically revert the transaction unless a=0.

I'll try and answer the explicit question in your post though: Regarding calling a function with fewer parameters than it expects, you just can't; or rather, if you do the EVM will not find the correct signature and execute the fallback function instead.

What you can do, is feed it dummy values for the arguments you don't care about (like in this case, since b is ignored in the function anyway).

• I have made some changes to the function by adding b argument too. I have also added one function calls that run correctly but does not give desired result. In the end I have added some more points. Jul 7, 2019 at 17:19
• What is the desired result ? Jul 7, 2019 at 19:13
• I want to the function to test that a and b should be always less than c for addition and multiplication. Jul 7, 2019 at 21:30
• c is zero in the code you've shown, it seems pointless. Maybe if you formulate your objective with real words instead of faceless variables (a, b, c, x, y), it would help you write code that actually achieves it. Jul 8, 2019 at 18:42

I have to agree with Ismael, you seem to lack some basic skills that a good javascript tutorial should fill. And anyway js is a crucial tool to work with smart contracts, starting with testing.

Nevertheless, it just dawned on me that maybe you are asking about how to use the pattern that OpenZeppelin applies on its SafeMath library:

``````import "./libs/SafeMath.sol";

contract test {
using SafeMath for uint256;

uint256 a = 4;