So this works:

 pragma solidity ^0.4.11;

  contract test{
    event Print(string _name, uint _value);
    function test() payable{
        uint testval = 5;
        Print('val',(testval * 1000000000000000000));
        Print('val2',(5 ether));

And I get the same value for val1 and val2. Is there anyway to do:

Print('val3',(testval ether);

I keep getting an error on the function and multiplying out my contract value by that amount is rather annoying


In my opinion it's best to deal in wei in the contracts. Go ahead and emit wei so clients get the true values in input/output.

Presentation is usually best treated as a client-side issue. You can use something like fromWei() to do the conversion.


Hope it helps.

| improve this answer | |

With the event you defined event Print(string _name, uint _value)

You should log the event like so...

function emitEvent(string _name, uint _value) public {
     Print(_name, _value);
| improve this answer | |

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.