0

In the following example,

   contract Simple {
        function arithmetics(uint _a, uint _b) returns (uint o_sum, uint o_product) {
            o_sum = _a + _b;
            o_product = _a * _b;
        }
    }
  1. How would one go about getting the result from arithmetics(5, 6)?
  2. And how would you declare a variable holding the result?

Thank you.

  • The Mathematics is not working...using "blind poker"..The sum is 0..A= any number, even irrational (i.e. π) ..(A *B) - (A *B squared) = 0.......B=1.618... – Hoot O'Connor Sep 4 '17 at 4:29
2

The answer is as follows:

var (sum, product) = arithmetics(5, 6);

hence, the results can be accessed via the sum and product variables.

| improve this answer | |
0

Yes, the official docs aren't the greatest. In short you would need to compile the function, make sure the contract is mined and then call the function with [contract].arithmetics.call(5,6)

I wrote steps in more detail here about how I got this kind of simple function working (using this contract example is towards the end). Maybe it will help you: https://alanbuxton.wordpress.com/2017/07/19/first-steps-with-ethereum-private-networks-and-smart-contracts-on-ubuntu-16-04/

| improve this answer | |
  • There's no multiply function or namespace in the code given in my question. – chuacw Sep 4 '17 at 4:55
  • Sorry, corrected function call. There are a number of steps to compile and mine your function, if you need assistance with those parts pls follow link and look towards bottom of the post – Alan Buxton Sep 4 '17 at 5:00
  • My question does not have compile or mine. – chuacw Sep 4 '17 at 5:07
  • Ah I see you answered it yourself :) – Alan Buxton Sep 4 '17 at 5:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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