3

I discovered Solidity two days ago but I couldn't imagine how difficult it would be to even get started. Most tutorials and documentation are outdated and google results are very sparse. I followed a tutorial from youtube by Reitweissner (which cut off half way) and I am trying to run this constructor from their code. What I would like to do at this time is display the address of the sender and of value. Is there some sort of console.log or similar that I can use? I have heard of Events but how would I display that event log in remix if that's the case?

pragma solidity ^0.4.0;

contract Purchase {
address seller;
uint value;

function Purchase() payable {
    seller = msg.sender;
    value = msg.value / 2;
    //Console.log(value); //expect value 4 since msg.value should be 8
    }
}

1 Answer 1

0

using the events you get this code :

pragma solidity ^0.4.6;

contract Purchase {
address seller;
uint value;
event output_value(uint indexed val,address add);
function Purchase() payable {
    seller = msg.sender;
    value = msg.value / 2;
    output_value(value,seller);
    //Console.log(value); //expect value 4 since msg.value should be 8
    }
}

in remix you'll get the value and the address enter image description here

0

Your Answer

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