1 Answer
1

Any function that you call which requires a transaction will not return a value, but the transaction receipt. Instead, you can call that function, which will simply run the function on the local node, return the result, and not actually emit a transaction.

You would need to change your code to something like this:

return instance.add.call(3,4)

This will return the value from the function rather than the transaction receipt which you are getting back now from instance.add(3,4).

The other option is to make your function a view or pure function, which does not require a transaction to call and will return the value:

This should work without needing to call the function. Here, we made the total variable local to the function, so it does not store or read any data on the blockchain itself, and thus can be treated as a pure function.