7

I read about using events from this source http://solidity.readthedocs.io/en/latest/contracts.html#events I used a simple multiply contract:

contract test1{
    uint a;
    event event_res(string msg,uint x);
      function test1(){
          a = 1;
      }
      function multiply (uint b){
          a = a*b;
        event_res("the value after multiplying is:",a); 
      }
      function getval()  returns(uint){
          return a;
      }
}

and executed sendtransaction as:

var testing = web3.eth.contract(interface).at(address);
var event = testing.event_res(function(error, result) {
    if (!error)
        console.log(result.args);
    else
        console.log(error);
});
var result = testing.multiply.sendTransaction(5,{from : web3.eth.coinbase},function(err,result){
        if(err)
        console.log(err);
});

I got multiple parameters as output in console as following:

{ msg: 'the value after multiplying is:',
  x: { [String: '5'] s: 1, e: 0, c: [ 5 ] } }

Can anyone tell me what these parameters(s,e and c) are and what they mean?

1

1 Answer 1

4

result.args is an object with 2 keys, msg and x as you've declared in your event_res.

x is a BigNumber object that is stringified to { [String: '5'] s: 1, e: 0, c: [ 5 ] }. You can use BigNumber methods, like results.args.x.toNumber() to see it better.

EDIT: Following was added to the question

Can anyone tell me what these parameters(s,e and c) are and what they mean?

Those are properties of the BigNumber object. It's out of scope here to go into the internals of a general external library like BigNumber.

The main thing that helps is to recognize that when you get an object that looks like it, is that it's probably a BigNumber and you can call methods on it, as well as perform other additional BigNumber operations (without needing to know its internals).

3
  • i would also like to know what arguments s,e and c [] mean?
    – Aditi
    Commented Jul 25, 2016 at 8:42
  • I see the question has been edited, so I've edited the answer too. They are internals of BigNumber, which are not necessary to be familiar with, just like you can use web3.js without needing to know what console.log(web3) means.
    – eth
    Commented Jul 25, 2016 at 9:14
  • Happy to help, and welcome to the community! If this answer or any other one solved your issue, please mark it as accepted by clicking on the big checkbox.
    – eth
    Commented Aug 17, 2016 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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