1

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

2

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.

https://github.com/ethereum/wiki/wiki/JavaScript-API#web3fromwei

Hope it helps.

0

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);
}

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.